Guest User

Untitled

a guest
Jan 21st, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. public class JNotifyExample
  2. public static void main(String[] args) throws InterruptedException, IOException
  3. {
  4. String dir = new File(args.length == 0 ? "." : args[0]).getCanonicalFile().getAbsolutePath();
  5. JNotify.addWatch(dir, FILE_ANY, true, new JNotifyListener()
  6. {
  7. public void fileRenamed(int wd, String rootPath, String oldName,
  8. String newName)
  9. {
  10. System.out.println("renamed " + rootPath + " : " + oldName + " -> " + newName);
  11. }
  12.  
  13. public void fileModified(int wd, String rootPath, String name)
  14. {
  15. System.out.println("modified " + rootPath + " : " + name);
  16. }
  17.  
  18. public void fileDeleted(int wd, String rootPath, String name)
  19. {
  20. System.out.println("deleted " + rootPath + " : " + name);
  21. }
  22.  
  23. public void fileCreated(int wd, String rootPath, String name)
  24. {
  25. System.out.println("created " + rootPath + " : " + name);
  26. }
  27. });
  28.  
  29. System.err.println("Monitoring " + dir + ", ctrl+c to stop");
  30. while (true) Thread.sleep(10000);
  31. }
  32. }
Add Comment
Please, Sign In to add comment