Java 7 WatchService - The process cannot access the file because it is being used by another process

Ok, I found a solution. I don't know if it is the best way to do this, but it works. Unfortunately, file.canRead() and file.canWrite() both return true, even if the file still locked by Windows. So I discovered that if I try to "rename" it with the same name, I know if Windows is working on it or not. So this is what I did:

    while(!sourceFile.renameTo(sourceFile)) {
        // Cannot read from file, windows still working on it.
        Thread.sleep(10);
    }

Solution given by Arundev worked for me.

I needed to add sleep time otherwise it wouldn't work for multiple requests and used to get the error "The process cannot access the file because it is being used by another process"

if (StandardWatchEventKinds.ENTRY_CREATE.equals(event.kind())) {
    try {
        Thread.sleep(3000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

// now do your intended jobs ...