我很难过这个。我知道renameTo是温和的,并且因各种原因而失败,但我不知道其中列出的原因是什么。 在同一文件夹中不存在具有相同名称的文件,也没有任何程序访问它。
for(int i = 0;i<languageList.size();i++){
FileUtils extraLangFiles = new FileUtils();
//File dest = new File(path.getCanonicalPath());
File temp = new File("./");
extraLangFiles.copyFileToDirectory(path, temp);
File tempFile = new File(getFilePath());
//Checks if file exists before making any edits
if(tempFile.exists()){
File tempName = new File(extractLanCode("./temp/" + tempFile.getName().replace(".xml", "")) + "_" + languageList.get(i)+".xml");
System.out.println("FileName Change - " + tempName.getName());
tempFile.renameTo(tempName);
//check if file is related to itd or project
if(isITD()==true){
File dest = new File(itdPath);
System.out.println("File Name() " + tempFile + ", " + dest);
extraLangFiles.copyFileToDirectory(tempFile, dest);
System.out.println("COPY - ITD");
tempFile.delete();
languagePath.add(dest + "/" + tempName);
}else{
File dest = new File(ProjectPath);
System.out.println("File Name() " + tempFile + ", " + dest);
extraLangFiles.copyFileToDirectory(tempFile, dest);
System.out.println("COPY - Project");
tempFile.delete();
languagePath.add(dest + "/" + tempName);
}
}
}
我的想法是它与copyFileToDirectly有关,也许是一个流从它开放。
顺便说一下,我坚持使用java 1.6,因此无法使用上述任何功能。