• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

file

 
smita mishra
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the I/O section of the Java Tutorial or the I/O chapter of Thinking in Java.
 
bhanushali bhavesh
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47231
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . 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."
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic