File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "file" Watch "file" New topic


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

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
bhanushali bhavesh

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

Joined: Oct 13, 2005
Posts: 46352
. . . 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."
I agree. Here's the link:
subject: file
It's not a secret anymore!