my dog learned polymorphism
The moose likes Beginning Java and the fly likes Replace a file using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Replace a file using java" Watch "Replace a file using java" New topic

Replace a file using java

An Sush
Ranch Hand

Joined: Jan 17, 2007
Posts: 47
Hi All,
I have a file which i want to replace with another one. Say /opt/IBM/installedApps/WebApplication.ear is to be replaced by /root/Desktop/NewFile.ear. Is there simple File operation to do so?
Or the only way is to delete the existing file, create a new file with the same name and read byte by byte from NewFile.ear and write in the newly created file?
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 607

What did you try that did not work?

Just Check out the Java File Io and you'll find API which could work with both the approaches that you mentioned!

Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
I agree. Here's the link:
subject: Replace a file using java
It's not a secret anymore!