Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query on File Copy.

 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends ,
I have a requirement like this .. when ever a file is created in a directory a java program should pick it up and place it in my local folder and should be taken for further processing.
So i wrote a Java thread that listens that directory indefinitely so when ever a file is placed in it then it'll copy that file to my local directory.

The problem is since a thread is listening the directory in a while loop ( while (true ) { .... } ) , i'm getting an exception like new file cannot be created in the directory since some other process is using the directory. Is there any solution for this .

Currently what i'm doing is i'm keeping a time interval so that the thread will sleep for 15 mins and after each 15 mins interval it checks the folder for new file ..
 
Scott Corley
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure how it is accomplished because I haven't looked at the code but it sounds like the hot folder concept in AntFlow, http://antflow.onionnetworks.com/download.html.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Scott Corley:
Not sure how it is accomplished because I haven't looked at the code but it sounds like the hot folder concept in AntFlow, http://antflow.onionnetworks.com/download.html.

YEP i have sorted out the problem .. I have opened a file for reading & since there was some exception the file reader was not closed ... !!
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic