• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to write a file in append mode?

 
Kamlesh Dhawale
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am creating a file and writing into it using FileWriter. I want to append to the file every time I write.So I create fileWriter using FileWriter(filename,true).
But still it overwrites the previous contents.
Does any one know the solution. Or an alternate way to wirte a file in append mode.This is JDK 1.2
Thanks,
 
Yvette Gonzalez
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using PrintWriter, as in:
PrintWriter writer = new PrintWriter(new FileOutputStream(filename, true));
Yvette
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!