2 Replies Latest reply on Aug 31, 2012 4:05 PM by 541426

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

      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!