是否有一个复杂的Java文件系统监视器,它是免费软件还是开源软件? [英] Is there a sophisticated file system monitor for Java which is freeware or open source?
问题描述
我正在寻找一个可以通知我文件系统更改的Java库。
I'm looking for a Java library which can notify me about changes on the file system.
我找到了一些免费的库,但他们都使用暴力检测,即定期轮询。其他的总是商业化的。
I found some free libraries, but they all use brute-force detection, i.e. polling in regular intervals. And the other ones are always commercial.
我正在寻找的是一个使用操作系统文件监控功能的库,即
Win32的FindFirstChangeNotification , FAM 以及其他操作系统上提供的任何内容。我不介意使用暴力作为后备,但对于Windows和Linux,它应该使用可用的操作系统功能。
What I'm looking for is a library which uses the file monitor functions from the OS, i.e. FindFirstChangeNotification for Win32, FAM for Linux and whatever is available on other OS. I don't mind if brute-force is used as fallback, but for Windows and Linux it should use the available OS features.
推荐答案
JNotify 似乎可以满足您的需求。
JNotify seems to do what you require.
轮询文件系统(例如,更新时间更改的目录)不会对系统造成重大负担,也不应打折扣。像Tomcat等应用程序使用它来管理几乎没有问题的热部署。
Polling a filesystem (say, a directory for update time changes) won't impose a significant load on your system, and shouldn't be discounted. Apps like Tomcat etc. use this for managing hot deploys with few problems.
现在不是很多帮助,但即将推出的Java 7有 WatchService 正是为了这个。
It's not a lot of help now, but the upcoming Java 7 has a WatchService precisely for this.
这篇关于是否有一个复杂的Java文件系统监视器,它是免费软件还是开源软件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!