Created
September 21, 2011 09:47
-
-
Save alcides/1231686 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JNotifyExample | |
public static void main(String[] args) throws InterruptedException, IOException | |
{ | |
String dir = new File(args.length == 0 ? "." : args[0]).getCanonicalFile().getAbsolutePath(); | |
JNotify.addWatch(dir, FILE_ANY, true, new JNotifyListener() | |
{ | |
public void fileRenamed(int wd, String rootPath, String oldName, | |
String newName) | |
{ | |
System.out.println("renamed " + rootPath + " : " + oldName + " -> " + newName); | |
} | |
public void fileModified(int wd, String rootPath, String name) | |
{ | |
System.out.println("modified " + rootPath + " : " + name); | |
} | |
public void fileDeleted(int wd, String rootPath, String name) | |
{ | |
System.out.println("deleted " + rootPath + " : " + name); | |
} | |
public void fileCreated(int wd, String rootPath, String name) | |
{ | |
System.out.println("created " + rootPath + " : " + name); | |
} | |
}); | |
System.err.println("Monitoring " + dir + ", ctrl+c to stop"); | |
while (true) Thread.sleep(10000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment