This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "file" Watch "file" New topic
Author

file

smita mishra
Ranch Hand

Joined: May 18, 2006
Posts: 31
How can I save Data to a File? I tried to write some Data into a File by passing Strings from console,by combining InputStreamReader with BufferedReader then passing BufferedReader to the constructor of PrintWriter.But the problem the data which I stored in one execution lost completely in another execution.How can I save Data in file?
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

See the I/O section of the Java Tutorial or the I/O chapter of Thinking in Java.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
bhanushali bhavesh
Greenhorn

Joined: Sep 21, 2005
Posts: 3
That implies that u are overwriting the file each time u execute the code , This can happen when u do a new BufferedWriter () thing .
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37941
    
  22
. . . overwriting the file . . .

You can avoid overwriting the file by altering the BufferedWriter and FileWriter constructors. It is very easy. See the API.

And please don't write posts in text language, but use full words. There are people from non-English speaking backgrounds who wouldn't understand words like "u."
 
wood burning stoves
 
subject: file
 
Similar Threads
How to read character stream and byte stream at the same time?
accept input about patients, write it to a file, display the file's contents
Internet Programming (Java) Need Help
Error setting file paths
Saving to a text file!