使用JNotify监控硬盘
来源:互联网 发布:网络本科学位证有用吗 编辑:程序博客网 时间:2024/04/30 11:40
String path = "c:/test";int mask = JNotify.FILE_CREATED | JNotify.FILE_DELETED | JNotify.FILE_MODIFIED| JNotify.FILE_RENAMED;boolean watchSubtree = true;int watchID = JNotify.addWatch(path, mask, watchSubtree, new JNotifyListener(){public void fileRenamed(int wd, String rootPath, String oldName, String newName){System.out.println("JNotifyTest.fileRenamed() : wd #" + wd + " root = " + rootPath + ", " + oldName + " -> " + newName);}public void fileModified(int wd, String rootPath, String name){System.out.println("JNotifyTest.fileModified() : wd #" + wd + " root = " + rootPath + ", " + name);}public void fileDeleted(int wd, String rootPath, String name){System.out.println("JNotifyTest.fileDeleted() : wd #" + wd + " root = " + rootPath+ ", " + name);}public void fileCreated(int wd, String rootPath, String name){System.out.println("JNotifyTest.fileCreated() : wd #" + wd + " root = " + rootPath+ ", " + name);}});// to remove watch:boolean res = JNotify.removeWatch(watchID);if (!res){// invalid watch ID specified.}
硬盘监控在很多场合都很有用处,例如在线文档转换,只要监控到有文件写入,即可触发在线文档转换程序。JNotify支持windows和Linux两大操作系统,并且支持64位的机器,在使用JNotify时,需要手动将JNotify.dll或者libjnotify.so复制到JRE的bin目录下,然后在你的JAVA工程编写如下代码:
0 0
- 使用JNotify监控硬盘
- 使用JNotify监控目录下文件变更
- JNotify使用
- JNotify使用
- JNotify使用
- JNotify文件目录监控
- JNotify的使用
- JNotify的使用
- JNotify的使用
- JNotify使用 样例
- JNotify
- JNotify使用实例与BUG修复
- java实现文件实时监控:Jnotify和FileAlteration
- 硬盘监控
- JNotify 的简单使用(Linux命令行环境)
- Jnotify在linux下的使用出现的问题解决
- java中Jnotify文件监视库的使用
- java监听硬盘的创建、修改删除文件的demo(需要jnotify-lib-0.93.rar )
- 下拉选项。。。spinner
- tomcat在server.xml修改默认的session名称
- 例看const与指针兼容性
- mongodb 2.6 新建用户
- Unity性能优化之Draw Call
- 使用JNotify监控硬盘
- hdu 3746 Cyclic Nacklace (kmp扩展—最小循环节)
- 日语五十音图。
- IOS 应用内购买
- leetcode_01_Two sum
- Android 解决点击EditText获取焦点时输入法占满手机屏幕的办法
- 浅谈实战中销售信的写作
- Oracle dblink详解
- 设计包含min函数的栈