java.nio.file.Files.move()のサンプル
サンプルコード
package com.arkgame.itstudy;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
public class FolderMoveDemo {
public static void main(String[] args) {
Path srcPath = Paths.get("C:\\testdata\\test-copy.txt");
Path destPath = Paths.get("C:\\testdata\\subdir\\test-moved.txt");
try {
Files.move(srcPath, destPath, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
e.printStackTrace();
}
}
}