tags:

views:

100

answers:

3

Is there a good way to detect deletes in Java? I know I can loop through the contents of a folder and compare the previous results, but is there a better event driven way?

+3  A: 

I think this can interest You: http://stackoverflow.com/questions/1031931/what-is-the-easiest-way-to-track-a-change-in-a-folder-in-java

Maciek Sawicki
Specifically look here: http://java.sun.com/developer/technicalArticles/javase/nio/#6 but bear in mind this is Java 7 functionality.
Jherico
+2  A: 

There's no pure-java way to do what you describe. Here's a project that uses the JNI to do filesystem monitoring on Windows and Lniux, but I don't endorse it (I merely found it through google).

Jonathan Feinberg
+1  A: 

The name of the Java 7 feature you'll be interested in (when it is properly available) is the WatchService.

Xanatos