Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to append to a text file  RSS feed

 
Ann Ron
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am writing a Java program which reads messages off of a queue and then formats the data and has to store this data in a text file,whenever my program runs it has to append to the text file already opened for that week and then it has to close this text file at the end of the week say on sunday nite @ 12.00 and reopen a new text file @ 12.01 sunday nite and start writing and appending to that file for that whole week and so on..
Any idea how to do this?
Any help appreciated.
Thanks.
Ann
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a PrintWriter built from a FileOutputStream that has set append equal to true.
Check out Timer and TimerTask on how to set up a regularly scheduled event.
Using these classes, you should be able to create a program that appends to a file, and at a certain time (say once a week), it switches to a new file.
If you have developed any code, provide that and we may be able to help you more. If you don't have any code yet, check out the classes I mentioned and try your hand at them, then post more detailed questions for further clarification.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!