【发布时间】:2017-07-11 11:19:20
【问题描述】:
我正在尝试在文件夹之间移动单个文件。我使用 file.renameTo() 来移动我的文件。
//moving the file to new folder
//this is success
boolean fileMoveCompleted = finalFileToProcess
.renameTo(new File(processingFolderName
+ File.separator + finalFileToProcess.getName()));
//now trying to move the renamed file to another folder
//this is failing
fileMoveCompleted = finalFileToProcess
.renameTo(new File(successFolderName
+ File.separator
+ finalFileToProcess.getName()));
在第一个renameTo 之后,文件路径仍指向旧路径。有什么办法可以将同一个文件移动到另一个目录?
【问题讨论】: