【Linux文件系统监控的Java类库 inotify-java】

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

示例代码:java


  1. try {
    面试

  2.             Inotify i = new Inotify();
    ide

  3.             InotifyEventListener e = new InotifyEventListener() {
    post


  4.                 @Override
    学习

  5.                 public void filesystemEventOccurred(InotifyEvent e) {
    spa

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

  7.                 }
    ci


  8.                 @Override
    postmessage

  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

相关文章
相关标签/搜索