当前位置: 首页 > 工具软件 > inotify-java > 使用案例 >

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

桓修能
2023-12-01

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");

}

 类似资料: