I have been writing a program for batch system using quartz and i find a problem,
if(!file.renameTo(new File(PATH_FILE_PROCESSED+file.getName())))System.out.println("Cannot Move File :"+file.getAbsolutePath());
else{
if(!file.delete())System.out.println("Cannot Delete File :"+file.getAbsolutePath());
}
i want to move file from one directory to another directory but i can't delete the file in the same process, from my analysis i think the file haven't finished copying then running the file.delete(); my question is, is there a way to wait until the file finished copying then run the file.delete? thanks
Renaming is almost instant as it doesn't copy the file, it just moves which directory it appears in (unless you are moving between filesystems)
On windows, you can't rename or delete if you have the file open somewhere. Make sure you have close()ed it properly.