Draph_89
asked on
Reads a Java Source File and Writes it Back
Write a program that reads a Java source file and writes it back without any changes under a new name.
ASKER
// File (or directory) with old name
File file = new File("oldname");
// File (or directory) with new name
File file2 = new File("newname");
// Rename file (or directory)
boolean success = file.renameTo(file2);
if (!success) {
// File was not successfully renamed
}
I have found this for the file, how would I get this portion of the program to read the file and write it back as a different name?
File file = new File("oldname");
// File (or directory) with new name
File file2 = new File("newname");
// Rename file (or directory)
boolean success = file.renameTo(file2);
if (!success) {
// File was not successfully renamed
}
I have found this for the file, how would I get this portion of the program to read the file and write it back as a different name?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad I could help.
Regards
Dave
Regards
Dave
http://javaalmanac.com/egs/java.nio/File2File.html