aspose file tools
The moose likes Java in General and the fly likes Writing to an output file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Writing to an output file" Watch "Writing to an output file" New topic
Author

Writing to an output file

c york
Greenhorn

Joined: Mar 16, 2006
Posts: 27
I am using the API FileWriter.
- FileWriter outputFile = new FileWriter("Output.txt");
I have fields that I had broken up using the StringTokenizer method and I am not sure how to use the out.write("string") to get the fields in the output file.
--------------------------------------------------------------------------------
Greg Charles
Bartender

Joined: Oct 01, 2001
Posts: 2539
    
  10

You write strings just exactly like that, except you've changed the name of the variable from outputFile to just out. That part won't work.

One warning though: the FileWriter will create Unicode text files. If you want regular text files (single byte characters), you should use a FileOutputStream instead. The drawback is that any non-ASCII charcters you may be using will have to be encoded and the specifics of encoding can get a little tricky.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Writing to an output file
 
Similar Threads
using Writer in JspFragment invoke() method
how to save contents of an TextArea
Writing to a file
problem in appending contents of file.
Is there a I/O method to convert text to html?