解説動画
Filesクラスを使うと、ファイルのコピー、移動、削除が簡単にできます。
■動画はこちら
■Youtube版の解説で使用しているソースコード
 動画と一緒にこちらも参考にどうぞ。
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class FilesTest {     public static void main(String[] args) {         try {             //コピー             Path copySrcPath = Paths.get("R:\\SAMPLEFOLDER\\TEST_CMD\\1_test_cpy\\from\\cTest.java");             Path copyDestPath = Paths.get("R:\\SAMPLEFOLDER\\TEST_CMD\\1_test_cpy\\to\\cTest.java");             Files.copy(copySrcPath,copyDestPath);             //移動             Path moveSrcPath = Paths.get("R:\\SAMPLEFOLDER\\TEST_CMD\\2_test_mov\\from\\mTest.java");             Path moveDestPath = Paths.get("R:\\SAMPLEFOLDER\\TEST_CMD\\2_test_mov\\to\\mTest.java");             Files.move(moveSrcPath, moveDestPath);             //削除             Path deleteSrcPath = Paths.get("R:\\SAMPLEFOLDER\\TEST_CMD\\3_test_del\\dTest.java");             Files.delete(deleteSrcPath);         } catch (IOException e) {             e.printStackTrace();         }     } } | 














