- /**
- * Move the file to the specified directory
- *
- * Move files from test folder to test2 folder
- *
- */
- public class MoveFile {
- public static void main(String[] args) {
- try {
- File afile = new File("C:\\test\\test.txt");
- if (afile.renameTo(new File("C:\\test2\\" + afile.getName()))) {
- System.out.println("File is moved successful!");
- } else {
- System.out.println("File is failed to move!");
- }
- } catch (Exception e) {
- e.printStackTrace ();
- }
- }
- }
java file move
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325022431&siteId=291194637
Ranking