File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes problem with code 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 » Beginning Java
Bookmark "problem with code" Watch "problem with code" New topic
Author

problem with code

Ravindra Suroju
Greenhorn

Joined: Mar 11, 2008
Posts: 14
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...



Best Regards,<br />Ravindra.
Stuart Smith
Ranch Hand

Joined: Mar 28, 2008
Posts: 54
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.


Dale Carnegie:<br />"Most of the important things in the world have been accomplished<br />by people who have kept on trying when there seemed to be no hope at all."
 
Consider Paul's rocket mass heater.
 
subject: problem with code
 
Similar Threads
Strange File Behavior
FileIO
writing text to file
Strange problem occurred while using IO from java Applet
Maulin, problem with file write