- 浏览: 269308 次
文章分类
最新评论
-
羽风之扬:
crazydayu 写道您好,我在启动的时候也遇到了这种错误, ...
linux tomcat日志错误Cannot run without an instance id & java.net.UnknownHostExceptio -
羽风之扬:
我的也[是这用错误,改过后没效果。这是我的截图,麻烦帮我看下吧 ...
linux tomcat日志错误Cannot run without an instance id & java.net.UnknownHostExceptio -
hamizhong:
...
Linux和Python脚本自动部署应用一例(2) -
crazydayu:
您好,我在启动的时候也遇到了这种错误,但是加上127.0.0. ...
linux tomcat日志错误Cannot run without an instance id & java.net.UnknownHostExceptio -
lg327969713:
wx_hello 写道你好,请教下,这个链接要配置ODBC数据 ...
Java连接FoxPro6.0数据库(测试)
学习Jnotify文件监视用例
研究文件监视(Windows),对文件的增加、修改、重命名、删除做记录,找到Java开源技术Jnotify,做了稍微学习,留下一点记录,以资备用,网络上资料有限。
package com.jnotify; import net.contentobjects.jnotify.JNotify; /** * Monitor file directory file (folder ) is created, modified, deleted, renamed files[folders] * (To adapt to a sub-folders). * JDK: 1.6.0_19 * JAR: jnotify-0.94.jar * @author Dennis Zhao * @createdTime:2012-09-28 * Technology from website: http://jnotify.sourceforge.net/ */ public class JNotifyTest { public static void main(String[] args) { JNotifyTest test = new JNotifyTest(); try { test.sample(); } catch (Exception e) { e.printStackTrace(); } } public void sample() throws Exception { // path to watch String path = "D:\\abc"; // watch mask, specify events you care about, // or JNotify.FILE_ANY for all events. int mask = JNotify.FILE_CREATED | JNotify.FILE_DELETED | JNotify.FILE_MODIFIED | JNotify.FILE_RENAMED; // watch subtree? boolean watchSubtree = true; // add actual watch int watchID = JNotify.addWatch(path, mask, watchSubtree, new Listener()); // sleep a little, the application will exit if you // don't (watching is asynchronous), depending on your // application, this may not be required Thread.sleep(15000); //Thread.sleep(5000); // to remove watch the watch boolean res = JNotify.removeWatch(watchID); if (!res) { // invalid watch ID specified. System.out.println("Delete from data : " + watchID); } } }
package com.jnotify; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import net.contentobjects.jnotify.JNotifyListener; /** * Listener implement * JDK: 1.6.0_19 * JAR: jnotify-0.94.jar * @author Dennis Zhao * @createdTime:2012-09-28 * Technology from website: http://jnotify.sourceforge.net/ */ public class Listener implements JNotifyListener { public void fileRenamed(int wd, String rootPath, String oldName, String newName) { writeTextAppend("Renamed==1==File path== [" + rootPath + File.separator + oldName + "] --> [" + rootPath + File.separator + newName + "]==time==" + System.currentTimeMillis()); //print("Renamed " + rootPath + " : " + oldName + " -> " + newName); operateDataDB2(wd,rootPath + File.separator + newName,"Renamed",rootPath,rootPath + File.separator + oldName,rootPath + File.separator + newName); } public void fileModified(int wd, String rootPath, String name) { writeTextAppend("Modified==2==File path== [" + rootPath + File.separator + name + "]==time==" + System.currentTimeMillis()); //print("Modified " + rootPath + " : " + name); operateDataDB2(wd,rootPath + File.separator + name,"Modified",rootPath,"",""); } public void fileDeleted(int wd, String rootPath, String name) { writeTextAppend("Deleted==3==File path== [" + rootPath + File.separator + name + "]==time==" + System.currentTimeMillis()); //print("Deleted " + rootPath + " : " + name); operateDataDB2(wd,rootPath + File.separator + name,"Deleted",rootPath,"",""); } public void fileCreated(int wd, String rootPath, String name) { writeTextAppend("Created==4==File path== [" + rootPath + File.separator + name + "]==time==" + System.currentTimeMillis()); //print("Created " + rootPath + " : " + name); operateDataDB2(wd,rootPath + File.separator + name,"Created",rootPath,"",""); } void print(String msg) { System.out.println(msg); } /** * * writeText * @param record * @return the void */ private void writeTextAppend(final String record) { try { FileWriter writer = new FileWriter("d:\\File_log.txt", true); writer.write(record + "\n"); writer.close(); } catch (IOException e) { e.printStackTrace(); } } /** * * oracle database test * operateDataOracle * @param wd * @param operatName * @param operateType * @param rootPath * @param oldName * @param newName * @return void */ private void operateDataOracle(int wd, String operatName, String operateType, String rootPath, String oldName, String newName) { Connection conn = null; try { Class.forName("oracle.jdbc.driver.OracleDriver"); conn = java.sql.DriverManager.getConnection("jdbc:oracle:thin:@10.199.130.221:1522:ORCL", "scott", "tiger"); String sql = "insert into t_file_log (ID, OP_NAME, OP_DATETIME, OP_ID, OP_TYPE, ROOT_PATH, OLD_NAME, NEW_NAME) " + "values (seq_file_log.nextval, ?, sysdate, ?, ?, ?, ?, ?)"; PreparedStatement pst = conn.prepareStatement(sql); pst.setString(1, operatName); pst.setInt(2, wd); pst.setString(3, operateType); pst.setString(4, rootPath); pst.setString(5, oldName); pst.setString(6, newName); pst.executeUpdate(); pst.close(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } finally { if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } } /** * * DB2 database test * operateDataDB2 * @param wd * @param operatName * @param operateType * @param rootPath * @param oldName * @param newName * @return void */ private void operateDataDB2(int wd, String operatName, String operateType, String rootPath, String oldName, String newName) { Connection conn = null; try { Class.forName("com.ibm.db2.jcc.DB2Driver"); conn = java.sql.DriverManager.getConnection( "jdbc:db2://10.199.30.249:50000/DB902:currentSchema=ORCL;", "SCOTT", "TIGER"); String sql = "insert into TRSUAT.t_file_log (ID, OP_NAME, OP_DATETIME, OP_ID, OP_TYPE, ROOT_PATH, OLD_NAME, NEW_NAME) " + "values (seq_file_log.nextval, ?, sysdate, ?, ?, ?, ?, ?)"; PreparedStatement pst = conn.prepareStatement(sql); pst.setString(1, operatName); pst.setInt(2, wd); pst.setString(3, operateType); pst.setString(4, rootPath); pst.setString(5, oldName); pst.setString(6, newName); pst.executeUpdate(); pst.close(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } finally { if (conn != null) { try { conn.close(); } catch (SQLException e) { e.printStackTrace(); } } } } }
注意地方:
增加启动命令项,
java -Djava.library.path=. -jar jnotify-VER.jar [dir]
这里有如图Ecplise下面简单设置,如下图
如需要实际业务操作,根据情况做适当调整。
发表评论
-
java多线程共享对象切换标志
2018-01-06 16:29 432直接上题: 要求创建三个线程,输出 ... -
编译时和运行时顺序输出笔记记录
2017-12-28 14:12 404package com.dennis.test.init; ... -
Java记事本二
2017-12-28 13:45 459//下面代码为两组分类示例 private sta ... -
mongodb在Java环境下简单使用
2015-09-16 18:42 1254mongodb在Java环境下简单使用,简单记录,简单增删查 ... -
Tomcat7+Nginx1.8+Redis2.6负载均衡简单配置
2015-09-06 16:13 1245为了缓解因为Web服务器的session所 ... -
Java简易cglib代码实现方式(AOP)
2015-05-25 17:12 933CGLIB(Code Generation Library) ... -
linux tomcat日志错误Cannot run without an instance id & java.net.UnknownHostExceptio
2015-03-14 17:51 4849linux环境下面出现这种问题(而windows下面可 ... -
quartz集群分布式(并发)部署解决方案-Spring
2015-03-14 17:37 5168项目中使用分布式并发部署定时任务,多台跨JVM,按照常理逻 ... -
redis基本命令、配置参数 - 简单示例(sub/pub)
2014-10-11 18:12 2516(一) redis命令集功能分析 转(htt ... -
计算机原码、反码、补码、位移码
2014-09-16 11:03 726计算机原码、反码、补 ... -
内螺旋数组java实现
2014-09-15 23:14 751最初学习C语言时,看到国外程序员的内螺旋实现,都懵了,感觉 ... -
排列组合
2013-10-17 20:58 0package org.dennis; import ... -
排列组合基本算法
2013-09-03 10:33 0import java.util.ArrayList; i ... -
动态反射代理实现机制两例代码比较(二)
2013-03-29 14:52 1010动态反射代理实现机制两例代码比较,最近研究设计 ... -
动态反射代理实现机制两例代码比较(一)
2013-03-29 14:31 922动态反射代理实现机制两例代码比较,最近研究设计 ... -
解决一例Was8.0异常java.lang.reflect.InvocationTargetException
2013-03-21 19:08 5350... -
Java拼音转换一例
2012-11-27 18:40 987工作中有时碰到将中文名转换成首字母拼音书写。以前工 ... -
Java工作记事本
2012-11-20 11:00 1139工作始终会遇到很多需要收集的资料,时间长了,难免 ... -
POI study
2012-09-19 13:52 2452工作需要研究POI技术导出Excel格式,目前实验 ... -
找出随机抽查数字
2012-08-16 16:50 960闲来无事,做一个简单随机查找数字小程序,闲的发慌,因为具体 ...
相关推荐
NULL 博文链接:https://andilyliao.iteye.com/blog/634586
jnotify32 位
jNotify漂亮的提示插件
JNotify,一个支持动态监控文件和文件夹(支持级联监控)的架包。在linux系统中,调用的是linux底层的inotify服务,只是添加了对子文件夹级联监控的功能。在windows中,需要添加附件的dll文件,因为windows默认没有...
这个是Jnotify的源码,相关配置,及jar包。是我千辛万苦找到的,希望能帮上大家,免去寻找的麻烦。
jnotify_64bit jnotify_64bit jnotify_64bit jnotify_64bit
通过java代码利用JNotify工具实现监控一个文件夹下的文件或者文件夹的动态变化,资料包含文件代码,maven依赖,dll动态库(win和linux)
jnotify(包含dll与so) 需要的下载..
基于 Jquery 的 Nitofication 元件. 提供很基本但實用的功能. 文檔大小只有2K.
对文件进行每五分钟的监控,把整个文件的内容全部传输至另一文件.以达到两个文件的一致性.
用java写的windows下的文件搜索程序,底层索引存储采用bst(二叉排序树),构造索引时采用深度递归算法(偏慢),只支持对文件的索引,不支持对文件夹的索引,采用jnotify监听文件的新建,修改,删除和重命名,同时自动...
jNotify:操作结果信息提示条
jnotify-lib-0.93 通过java调用dll 实现目录变化的系统事件通知,比轮询 多线程监控 更胜一筹
jnotify-lib-0.93.rar java监听硬盘的引用包,可以通过java来监听到硬盘上的创建、修改、删除文件的动作等等
JNotify 基于Jquery的消息提示插件 参数 var defaults = { // 容器 notifyContainer 'className':'JNotify-danger', //容器 notifyContainer附加类名 'theme':'error', // 主题 “success”、“error”、...
openrasp-jnotify一个改造过的 jnotify 版本改造点,补全linux inotify 事件监听,使监听事件更全面支持更低版本的 linux内核支持32位linux使用 IDEA 编译即可
文件复制操作,文件夹监控,包括jnotify,java 7 WatchService
在电脑C盘中找到Idea的插件目录,然后直接将这个文件拷贝进去即可使用
jnotify监控文件变化,并将变化的文件通过linux rsync 命令同步到config.properties配置中配置的服务器 ##文件结构说明 src 为java源代码文件 target 为项目编译文件输出目录 pom.xml 为maven项目配置文件 FileSync ...