inotify-java是一个在 Linux 下对文件系统的更改进行监控的 java库。

示例代码:


  1. try {

  2.             Inotify i = new Inotify();

  3.             InotifyEventListener e = new InotifyEventListener() {


  4.                 @Override

  5.                 public void filesystemEventOccurred(InotifyEvent e) {

  6.                     System.out.println("inotify event occurred!");

  7.                 }


  8.                 @Override

  9.                 public void queueFull(EventQueueFull e) {

  10.                     System.out.println("inotify event queue: " + e.getSource() +

  11.                             " is full!");

  12.                 }

  13.                 

  14.             };

  15.             i.addInotifyEventListener(e);

  16.             i.addWatch(System.getProperty("user.home"), Constants.IN_ACCESS);

  17.         } catch (UnsatisfiedLinkError e) {

  18.             System.err.println("unsatisfied link error");

  19.         } catch (UserLimitException e) {

  20.             System.err.println("user limit exception");

  21.         } catch (SystemLimitException e) {

  22.             System.err.println("system limit exception");

  23.         } catch (InsufficientKernelMemoryException e) {

  24.             System.err.println("insufficient kernel memory exception");

  25.         }

更多java,java学习,java面试题  http://techfoxbbs.com