We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
是的当然。 Apache VFS 正是这样做的。您可以在 http://commons.apache.org/vfs/ 下找到它。它是一个纯java库,可以监视文件,并且非常容易使用:
上面的代码将监视文件c:/MyFile.txt。如果发生变化,则调用对象 new MyListener()。
yes, of course. Apache VFS does exactly this. you can find it under http://commons.apache.org/vfs/. It's a pure java library that can monitor files and it's pretty easy to use:
the code above will monitor the file c:/MyFile.txt. if it changes, the object new MyListener() is called.
一个纯粹的 Java 库来做这件事是不可能的;如果你想避免轮询,你需要一个本机组件。
http://wiki.netbeans.org/NativeFileNotifications 提供了有关可用本机 API 和各种 Java 的一些信息包装它们的库。
A pure Java library for this is impossible; you need a native component if you want to avoid polling.
http://wiki.netbeans.org/NativeFileNotifications gives some information about both the available native APIs and various Java libraries wrapping them.
Jetbrains IntelliJ IDEA 有一个组件“虚拟文件系统”它会触发本机文件系统观察程序,将底层文件系统更改通知回 IDEA。两年来,Jetbrains 一直在发布包含该组件的开源版本。它适用于 Java 6。
它是在 Apache 2.0 许可证下发布的,如常见问题解答页面中所述。
Jetbrains IntelliJ IDEA has a component 'Virtual File System' which fires a native file system watcher notifying underlying file system changes back to IDEA. For two years Jetbrains has been releasing an open source version which should be containing the component. It works with Java 6.
It's released under Apache 2.0 license as claimed in the FAQ page.