wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes move file A to file B Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "move file A to file B" Watch "move file A to file B" New topic
Author

move file A to file B

Ronnie Phelps
Ranch Hand

Joined: Mar 12, 2001
Posts: 329
Does anyone have any suggestions on the bestway of replacing the contents of one file with the contents of another...given that both files exist.
Ryan Langley
Ranch Hand

Joined: May 10, 2001
Posts: 46
Hello,
The default behavior of the File IO streams is to overwrite what was already in the file. IF you want to append, you have to specifically flag it in the constructor to do so. If the data is important to keep around, or is needed for auditing or something, then I would make a back-up copy of the file before you overwrite it. You can use whatever schema you want for that, and it depends on how long you want to keep back-up copy's around. Here is a basic app that I wrote up real quick to show some of the ways you can use File IO. Hope this helps in answering your question!


------------------
Cheers,
RL


Cheers,<P>RL
Ronnie Phelps
Ranch Hand

Joined: Mar 12, 2001
Posts: 329
Thanks Ryan..that was really helpful!! I need to brush up on my I/O knowledge. :-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: move file A to file B