This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with code

 
Ravindra Suroju
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have the code to create a text file and append some data into it and when i run the same program again why is it overwriting the existing file instead of appending the new data... please help me...

 
Stuart Smith
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks to me that you are creating a new instance each time the code runs, so instead of opening the file for reading it is writing over it each time.

What I think you need to do is check if the file exsists and if it does not write to it like your code does right now but open it and then append it, I can't give you advice on the code to use as I am new to Java but that seems to be the problem from what I can see, hope that helps.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic