What is the most efficient way to detect file modification in Java?
I read about file polling, but the polling approach has a number of drawbacks that become apparent as the number of files viewed increases. I prefer not to use polling, but a number of solutions on the Internet seem to indicate polling files as the recommended method. I was hoping that maybe the OS-related callback solution for updating the file system is this possible on both Linux and Windows?
Given that I currently only intend to “watch” 2 files, I am still open to solving file polling. Ideally, I hope that polling files will not have a big impact on performance.
I know Java 7 WatchService, but since 7 is not officially released, I hesitate to use this approach or JNI libraries.
Many thanks!
EDIT: File polling seems to be the way to go. If someone could recommend the safest / most efficient way to implement file polling, that would be great.
source
share