I have a watch service watching a directory. Once files are created, I\'m processing the directory and updating a tree view.
This works fine on ENTRY_DELETE
The event is triggered when a file is created. The file needs to be created before it can be written to. A file doesn't simply appear once it is fully written, it appears once it is created.
What you can do is once you get the creation event:
rw mode (so read & write access)A simplified example:
File lockFile = new File( "file_to_lock" );
FileChannel channel = new RandomAccessFile( lockFile, "rw" ).getChannel( );
channel.lock( );