Im developing a P2P backup system for LANs in Java. I have the following problem
Lets say there is a file called test.txt in my Windows file system. My software is running on Windows at this time. The user opens up the file through Windows Explorer and modifies it or deletes it altogether.
Is there a way I can ask WIndows to alert my software when this happens.? Essentially I need a way to give a list of files to Windows and then listen for any activity on those files
First, you make use of the Java Native Interface. Write a native library for Windows that uses the .NET class, FileSystemWatcher.
This next one isn't the greatest approach. It's more a brute force way, but it still works. Write your own FileSystemListener class that gets a list of files, and checks the timestamp of it's last modification and compares the two.
Can you please provide some more details about JNI. I am unable to find any quick tutorials on this topic on the Web. Most of them refer to the book. I have never heard of this before, so if you can provide a link that quickly explains file system interfaces, that would be very helpful.