This discussion is archived
2 Replies Latest reply: Aug 31, 2012 9:05 AM by 541426 RSS

java.io.FileNotFoundException: The process cannot access the file because..

541426 Newbie
Currently Being Moderated
Hi,
I encountered this problem while working with the Watch Service API in Java 7. I registered a directory with Watch Service to be able to monitor any new files begin created/uploaded via copy or FTP method. The watch service kicks in as soon as it receives the watch key. However, after I obtain the context from the Watch Event when I try to read the file I get "java.io.FileNotFoundException: C:\Documents and Settings\TestUser\logs\test.log (The process cannot access the file because it is being used by another process)
at java.io.FileInputStream.open(Native Method)
     at java.io.FileInputStream.<init>(FileInputStream.java:138)
     at java.io.FileInputStream.<init>(FileInputStream.java:97)
     at com.skis.tests.MsgProcessor.processEvents(MsgProcessor.java:67)
     at com.skis.tests.MsgProcessor.main(MsgProcessor.java:184)"

Has any one come across similar problem? All suggestions and advices are welcome.

Thanks in Advance!
skis

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points