您可以使用此(或任何变体):
Files.copy(src, dst, StandardCopyOption.REPLACE_EXISTING);
另外,我建议您使用
File.separator或
/代替
\使其兼容于多个操作系统.
由于您不确定如何临时存储文件,因此请查看
ArrayList:
List<File> files = new ArrayList();files.add(foundFile);
要将a
List个文件移动到单个目录中:
List<File> files = ...;String path = "C:/destination/";for(File file : files) { Files.copy(file.toPath(), (new File(path + file.getName())).toPath(), StandardCopyOption.REPLACE_EXISTING);}


