0

I'm trying to index a file structure (not actual data) relative to a specific path on my local disk. Initially I load the file structure to memory then listen for real changes in the directory. If one occurs then I update the relevant indexed files in internal memory. Not unlike what dropbox seems to do?

Does there exist any java-library which can do this? I don't really want to implement this from scratch.

2 Answers 2

3

To listen for changes on a file, you can have a look at apache commons io which has a FileAlterationMonitor.

Sign up to request clarification or add additional context in comments.

2 Comments

I was looking for the method to store the meta-data and manage it. Not how to monitor it. I was using JNotify for that (though FileAlterationMonitor seems good as well).
@Zoiros My bad, I thought the point was about monitoring file changes. You can have a look at JBoss VFS or Apache Commons VFS
2

Java 7, as part of NIO.2, has the WatchService API.

The WatchService API is designed for applications that need to be notified about file change events.

2 Comments

I am running on a mac. I'm having truble getting Java 7, let alone NIO.2, to work. Any suggestions?
@Zorios - get a different computer for doing your Java development and running Java applications. Or use a different language for developing Mac applications.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.