I have a TimerTask that looks for a file on a directory. Once it sees the file, it parses it and puts it in the DB using several objects. After all of that is done, the system is supposed to delete the file so that it does not just sit there parsing it. But, there seems to be a lock on the directory. I can't even delete it manually when the timertask is polling.
How do I kill the timertask long enough to delete a file through the software using: boolean isDeleted = file.delete();? No one monitors these directories. I have created a system that allows files to be uploaded to the hard drive (automatically) and then once parsed, I need the files to be killed or my timer will just keep parsing the files over and over again. Any thoughts? The code that is not working is below.
In summary, Another class (not shown) invokes the TimeLapFiles class. That class is the invoker. It polls every 10 seconds. The file takes miliseconds to process so there should be no use of the file by the time that the delete method is called. But the lock on the directory won't allow any delete at all.
For those of you form the US, happy 4th!
Cheers, Al [ July 01, 2005: Message edited by: Al Wells ]
That syntax for File depends on the "current" directory not the root directory - you may not be getting a valid File object. Also, I don't see where you close readLap - so your program still has the file open, creating a lock. Wouldn't it be simpler to have the parsing program close and delete the file directly? Bill
Ever since I found this suit I've felt strange new needs. And a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss