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

Trouble appending new data to an existing file  RSS feed

 
Michael Crutcher
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks in advance for any help you all might be able to extend. I'm having a prouble appending new data to a file. Its a character file and I can't get it to not overwrite my old file

I think that I'm doing what I'm supposed to: setting the FileWriter to append mode and closing the streams. I've tried it without the BufferedWriter, but it does the same thing. I'm stumped, this should be really easy but its not working. Can anybody think of what other issues might be causing this behaviour?
Thanks,
Michael Crutcher
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody think of what other issues might be causing this behaviour?
Not in the code shown. Is it possible your "lotsa code making a String called output" has some additional file-writing code in it that you've forgotten about? Try putting in a few debug checks before and after the file is written:

From this you may be able to tell if some other code is affecting the file before or after you do your write. Good luck...
 
Michael Crutcher
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help Jim, it turned out that you were correct, I was editing this file in a different part of the code. I was writing a SQL parser and the sample script had a drop statement (that caused the deletion of the file in question) that I didn't notice.
Sometimes when you look at something for so long you miss the really obvious stuff.
Thanks,
Michael Crutcher
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!