aspose file tools*
The moose likes I/O and Streams and the fly likes Query on File Copy. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Query on File Copy." Watch "Query on File Copy." New topic
Author

Query on File Copy.

Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
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 ..


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Scott Corley
Greenhorn

Joined: Nov 28, 2004
Posts: 5
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

Joined: Sep 28, 2004
Posts: 1228
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Query on File Copy.