Originally Posted by
ravian
Thanks but it only works if file is not being used. I have a Java thread that is writing to the text file. The second thread tries to delete the file. Is it possible?
Hmm.... it's my understanding that it might not be able to delete a file that is being used - that's just plain OS/Software fundamentals. Ever try deleting your Word or Open Office document that's currently open? You get a lovely popup message saying "you must close this file before you can delete it"... or something to that effect. But maybe there is a way in Java... maybe someone knows. What we do know, is that even though you have two threads, at some point the thread using the file will eventually stop using the file, unless you've implemented an infinite loop into the program.... interesting question nevertheless.