Link to home
Start Free TrialLog in
Avatar of Draph_89
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.
Avatar of boonleng
boonleng
Flag of Malaysia image

Avatar of Draph_89
Draph_89

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?
SOLUTION
Avatar of boonleng
boonleng
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Glad I could help.

Regards
Dave