ryk
ryk

Reputation: 153

Watching a Directory for Changes in Java 7

I am interested in actively monitoring my hard drive using the java.nio classes and indexing any modified files. I came across the following documentation http://docs.oracle.com/javase/tutorial/essential/io/notification.html for watching any changes to a directory. The section titled "When to Use and Not Use This API" clearly states that this API is not designed for indexing a hard drive. I am trying to understand why not and it may be that my use case may be slightly different in which it does not hit those limits Can someone explain the exact reason why Java advises against such use?

Upvotes: 0

Views: 72

Answers (1)

yole
yole

Reputation: 97308

This is actually explained right there. They advise against using the API for that purpose because not all operating systems support file system change notifications, and the performance will not be acceptable if you try to use this on an OS that doesn't support it.

If you're building a program for your own use and you know that your OS does support FS change notifications, you can use this API for your purpose.

Upvotes: 1

Related Questions