inotify-java是一個在 Linux 下對文件系統的更改進行監控的 java庫。html 示例代碼:java
try { 面試
Inotify i = new Inotify(); ide
InotifyEventListener e = new InotifyEventListener() { post
@Override 學習
public void filesystemEventOccurred(InotifyEvent e) { spa
System.out.println("inotify event occurred!"); htm
} ci
@Override postmessage
public void queueFull(EventQueueFull e) {
System.out.println("inotify event queue: " + e.getSource() +
" is full!");
}
};
i.addInotifyEventListener(e);
i.addWatch(System.getProperty("user.home"), Constants.IN_ACCESS);
} catch (UnsatisfiedLinkError e) {
System.err.println("unsatisfied link error");
} catch (UserLimitException e) {
System.err.println("user limit exception");
} catch (SystemLimitException e) {
System.err.println("system limit exception");
} catch (InsufficientKernelMemoryException e) {
System.err.println("insufficient kernel memory exception");
}
|