This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes EJB and other Java EE Technologies and the fly likes Dynamically reading the files at runtime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Dynamically reading the files at runtime" Watch "Dynamically reading the files at runtime" New topic
Author

Dynamically reading the files at runtime

Faraz Ka
Ranch Hand

Joined: Jun 01, 2013
Posts: 53
Hello,

My web Application when gets started reads from a file system for files and does some processing.
Every time the folder gets updated with new files, the web Application needs to be relaunched.

Any clue how to make it dynamic so that when the new file gets added it is picked for processing without a restart?

Thanks,
Faraz
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41599
    
  55
If you're using Java 7 you can use a built-in API: http://docs.oracle.com/javase/tutorial/essential/io/notification.html. Otherwise you will have to write your own task that scans the directory regularly for changes (maybe using the java.util.Timer and TimerTask classes).


Ping & DNS - my free Android networking tools app
Faraz Ka
Ranch Hand

Joined: Jun 01, 2013
Posts: 53
Hello Ulf,

I'm using Java 7 and hence will try out the API that you mentioned.

Thanks,
Faraz
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamically reading the files at runtime