This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
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!