Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Check folder and start program execution further

 
Vazzdoin Rocko
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on a distributed kind of Project in which i have to call 1 program from another according to requirement.
My problem is that in this whole process i have to check a folder, i.e. i have to keep checking a folder if it's populated with one or more files or not, if yes than call another Jar file
in process, and if not than keep checking it untill it's populated or not. But m unable to do that.. please help me in that issue. Paste some sample code if available.
Thanks.
 
Abhijeet Ravankar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to make this multithreaded.


 
Prashant Hurria
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can use an Opensource Utility use Jnotify it will save you the developement and testing time.
You can make classes implementing the call back interface of JNotify. Whenever a file comes you app gets the notification. Couldn't have been neater no pooling required . JNotify supplies Native files (.dll for windows .so for linux) I have tested it extensivally on Windows and Linux it works pretty well .....

Another option is JPoller :Advantage no Native calls pure java. Disadvantage: It pools based on the polling frequency you set.
http://jpoller.sourceforge.net
http://jnotify.sourceforge.net

If you have any problem which you are not able to solve after help from Web Search lemme know .....

 
Vazzdoin Rocko
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your precious replies . Well i've solved that problem through a simple method. I have run a infinite loop and am checking the folder if it has some file or not at every 10 minutes. I've used Thread.sleep() for waiting. It was a simple glitch,well i will test it through your methods too , but let me complete this project first . Thanks once again .Cheers
 
Riyas Hameed
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

My requirement is the same only, what i have to do means I keep on watching the folder in a C: \sourcefolder drive if the folder is updated with new file then I have to transfer the files to server machine .meanwhile at the same I have to find whether the file is fully written , why because some of the process will be writting the files in that folder I have check whether the file is fully written then i have to tarnsfer .i should not transfer the file if its partially written .

I am working on stand alone networking(JAVA) project , I need to transfer files from client to server when ever any new files added to the client folder.

please advise me to solve this.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic