IntelliJ Java IDE
The moose likes I/O and Streams and the fly likes strings to file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Reply Bookmark "strings to file" Watch "strings to file" New topic
Author

strings to file

alleykat
Greenhorn

Joined: Jan 23, 2002
Posts: 3
Hi again. I am trying to write a String to a file using :
FileWriter frOut = new FileWriter("OUTPUT.TXT");
String t = new String("test");
frOut.write(t);
//answer to own question (search is your friend)
//** frOut.close(); is needed
The file is created but nothing is written. I have built the string within the program and simply wish to store it as a text file.
Thanks again,
Allen
[ January 25, 2002: Message edited by: alleykat ]
Roy Ben Ami
Ranch Hand

Joined: Jan 13, 2002
Posts: 732
so u got the answer right?
just close it and u will be fine.
Muhammad sibtain
Greenhorn

Joined: Aug 31, 2001
Posts: 17
You must have to close the stream to flush all the data to the file what ever you write, it goes to stream either use
frOut.flush() or
frOut.close() to make data persistant.
Regards, Sibtain
 
 
subject: strings to file
 
Threads others viewed
FileWriter??
Again an old question..pls
Converting String to XML file?
Text Formating and FileWriter
FileWriter.write(String str)
IntelliJ Java IDE