inotify-java是一个在 Linux 下对文件系统的更改进行监控的
java库。
示例代码:
-
try {
-
Inotify i = new Inotify();
-
InotifyEventListener e = new InotifyEventListener() {
-
-
@Override
-
public void filesystemEventOccurred(InotifyEvent e) {
-
System.out.println("inotify event occurred!");
-
}
-
-
@Override
-
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");
-
}
|
更多java,java学习,java面试题 http://techfoxbbs.com【Linux文件系统监控的Java类库 inotify-java】
原文:http://blog.csdn.net/u014714340/article/details/45167827