Java-Renaming a file

import java.io.*;

class TestFile {
public static void main(String[] args) throws Exception {
File file = new File(args[0]);
System.out.println(file.getAbsolutePath());

File oldFile = new File("a.txt");
File newFile = new File("b.txt");
oldFile.renameTo(newFile);

if (new File("a.txt").renameTo(new File("b.txt"))) {
} else {
}

}
}

Post a Comment

0 Comments