I'm trying to use Java 7 and WatchService to monitor when folders are added to a folder (by being copied from a different location), then I want to act on the files within the newly created folder.
On OSX it works as I expect, I don't receive notification of new folder creation until the folder and its contents have been copied over. But on Windows I receive the key event on the folder creation before the contents of the folder have been copied so when I try to process the files within the folder there are not there, usually just the first file is there.
My current workaround is after receiving the folder notification I sleep for 10 seconds to wait for the files within to be copied over but this is not very satisfactory because the size of folders can vary considerably so Im going to be sleeping not long enough or too long most of the time.
Why the difference between OSX and Windows, and how can I solve my problem on Windows ?