我使用FileUtils.deleteQuietly()
方法在复制到其他一些地方后删除文件。但它没有删除文件,文件也停留在同一条路径中。
File folder = new File(Marker_Source_path);
File[] listOfFiles = folder.listFiles();
if(folder.exists() && folder.isDirectory() && folder.list().length>0)
{
for (int i = 0;i<listOfFiles.length; i++)
{
if (listOfFiles[i].isFile())
{
String Filename= listOfFiles[i].getName();
String Filename_path=listOfFiles[i].getAbsolutePath();
File File_with_path=new File(Filename_path);
FileUtils.copyFileToDirectory(File_with_path, destinationDir2_TITLE_MM);
FileUtils.copyFileToDirectory(File_with_path, destinationDir3_PUB_TYPE);
FileUtils.copyFileToDirectory(File_with_path, destinationDir4_ISSUE_FREQ);
FileUtils.copyFileToDirectory(File_with_path, destinationDir4_VOL_ISSUE);
System.out.println("Marker File : " + Filename + " Moved to destination Dir : "+ destinationDir2_TITLE_MM.getAbsolutePath() + "
Successfully...");
Boolean check_del=FileUtils.deleteQuietly(File_with_path);
System.out.println("Is File deleted : "+check_del);
}
}
}
else
{
System.out.println("No Markers to Copy....");
}
答案 0 :(得分:1)