首页 > 编程语言 > 详细

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

时间:2015-04-21 11:22:38      阅读:248      评论:0      收藏:0      [点我收藏+]

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

示例代码:


  1. try {

  2.             Inotify i = new Inotify();

  3.             InotifyEventListener e = new InotifyEventListener() {


  4.                 @Override

  5.                 public void filesystemEventOccurred(InotifyEvent e) {

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

  7.                 }


  8.                 @Override

  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


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

原文:http://melorogee.blog.51cto.com/6909056/1636389

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!