This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread 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 Murach's Java Servlets and JSP this week in the Servlets 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: 41068
    
  43
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
 
jQuery in Action, 2nd edition
 
subject: Dynamically reading the files at runtime
 
Similar Threads
Please anwer to my question?
Ent Java Prog w/ IBM WAS - Question Chapter 15
Problem in connecting java web application with database using context file in Tomcat 7
Difference between include directive and jsp:include
Java Dynamic Servlet