JNotify: Was tut sich im Dateisystem?
Die kleine (native) unter Linux und Windows arbeitende Bibliothek JNotify meldet Änderungen an Dateien. Ein Beispiel:
String path = "c:/";int mask = JNotify.FILE_CREATED | JNotify.FILE_DELETED | JNotify.FILE_MODIFIED | JNotify.FILE_RENAMED;boolean watchSubtree = true;int watchID = JNotify.addWatch(path, mask, watchSubtree, new JNotifyListener(){@Overridepublic void fileCreated( int arg0, String arg1, String arg2 ){ System.out.println( "created" );}@Overridepublic void fileDeleted( int arg0, String arg1, String arg2 ){ System.out.println( "deleted" );}@Overridepublic void fileModified( int arg0, String arg1, String arg2 ){ System.out.println( "modified" );}@Overridepublic void fileRenamed( int arg0, String arg1, String arg2, String arg3 ){ System.out.println( "renamed" );}} );
Und am Ende:
JNotify.removeWatch(watchID);