標籤:java面試題 java java學習
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】