Automatically reload modified files in Java

I have many configuration files that change the behavior of my application. I want to be able to make changes, and it is immediately reflected in the application when saving the file. Is there a Java library to help with this?

I could just keep a list of files with my timestamps and constantly check the background thread when the timestamp changes. Doesn't seem too complicated, but maybe there is a more efficient way to do this? Custom triggers, when some properties have changed, will be enjoyable.

I am using Spring 3.1, is there a built-in mechanism or solution that works great with Spring?

UPDATE Apparently, JDK7 now includes this functionality through the Watch Service API : โ€œMost file system implementations have their own support for file change notifications. The Watch Service API uses this support where it is available. However, when the file system does not support this mechanism "The viewer will be polling the file system, waiting for events." So this will be my motivation for switching to JDK7.

+7
source share
1 answer

All Articles