I'm having some difficulties with my java application. It scans a folder for movie files and then it sorts them in different folders, this is working fine. Now I changed it to always scanning instead of only when the application starts. The problem is that when I now copy a file into the folder that is being scanned it immediately starts sorting, so the copying is a lot slower. My question is: is there a way to check if the file is done copying before my application sorts it?
Asked
Active
Viewed 43 times
0
-
1ever heard of flag checks... – CoderNeji Jul 30 '15 at 08:43
-
by the way question is too broad and not salvagable... atleast not without some code – CoderNeji Jul 30 '15 at 08:43
-
@CoderNeji - it would be more helpful if you gave a link to what you mean by "flag checks" rather than sneering. Google returns results like this one: http://www.checks-superstore.com/Flags-Checks.aspx – Andy Turner Jul 30 '15 at 08:43
-
1You might implement a directory watch service like in the Java tutorial https://docs.oracle.com/javase/tutorial/essential/io/notification.html – SubOptimal Jul 30 '15 at 08:46
-
@CoderNeji nope never heard of, maybe you can explain? – Rob Jul 30 '15 at 08:46
-
It means have a boolean value as a flag and before sorting just check the value of that flag... Change the value of flag to true if the copying is done and check the value... if true is stored in flag then process with sorting... to check if if copying or not use directory watch service as told by @SubOptimal – CoderNeji Jul 30 '15 at 08:48
-
I mean that I am copying files with windows, not with my application, then I sort it with my application where it copies. So I need a way to check if windows is done copying – Rob Jul 30 '15 at 08:50
-
You might find the following question useful: http://stackoverflow.com/questions/750471/how-to-know-whether-a-file-copying-is-in-progress-complete-in-java-1-6 (Although I'm not convinced that that question is a duplicate of the NIO Watcher one) – Edd Jul 30 '15 at 15:16
-
Thanks everyone, I think I know how to do this. I'm going to try! – Rob Jul 30 '15 at 16:28