paradigmatic paradigmatic - 1 year ago 118
Java Question

WatchService for Java 6

Java 7 introduced

for monitoring file systems continuously. Is there a backport for Java 6 ?

Are there pure Java libraries with similar features ?

Answer Source

yes, of course. Apache VFS does exactly this. you can find it under It's a pure java library that can monitor files and it's pretty easy to use:

FileSystemManager manager = VFS.getManager();
FileObject file= manager.resolveFile("c:/MyFile.txt");

DefaultFileMonitor fm = new DefaultFileMonitor(new MyListener());

the code aboive will monitore the file c:/MyFile.txt. if it changes, the object new MyListener() is called.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download