java 复制文件

java 复制文件
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths ;
import java.nio.file.Files;
 

Path sourcePath = Paths.get("/storage/emulated/0/Android/media/images/19/25.jpg"); Path destinationPath = Paths.get("/storage/emulated/0/Android/media/images/25.jpg"); try { Files.copy(sourcePath, destinationPath); System.out.println("文件已成功复制到目标位置。"); } catch(IOException e){ System.err.println("复制文件时出错:" + e.getMessage()); }

 

posted @ 2024-04-11 16:10  Demiwang  阅读(11)  评论(0)    收藏  举报