Monday, March 11, 2013

Java 6 File Monitoring Example

I was asked today how you would monitor a file for changes using Java 6. Since Java 7 has added some great File handling features that I use, it was a reminder that not everyone is so lucky to use Java 7. I remembered an example from Geosoft (I remembered it because I liked the name). I went looking and I found their example code It is a simple and elegant solution to monitoring files and directories for changes.

This is by no means a complete example, but does show a simple technique.


m1k0 said...

JDK 7 has problem with some filesystems like CIFS/SMB

Simple way is to use pooling implementation from OpenJDK

John Yeary said...

Thanks for the additional information.

The target audience for this post though was the JDK 6 user who can not upgrade for any number of reasons. This technique will work on JDK 7, but there are better options available.

I have found some filesystem issues too with implementations. You mentioned CIFS/SMB, but I have found an incomplete implementation on my mac too.

Popular Posts