java.nio.file.NoSuchFileException on WatchService
358893Feb 27 2013 — edited Feb 28 2013Hi,
I am testing a program using Java 7 WatchService to watch a directory and get an error:
java.nio.file.NoSuchFileException: /media/C852-8B2A
java.nio.file.NoSuchFileException: /media/C852-8B2A
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.asIOException(UnixException.java:111)
at sun.nio.fs.LinuxWatchService$Poller.implRegister(LinuxWatchService.java:243)
at sun.nio.fs.AbstractPoller.processRequests(AbstractPoller.java:260)
at sun.nio.fs.LinuxWatchService$Poller.run(LinuxWatchService.java:326)
at java.lang.Thread.run(Thread.java:722)
this exception shows on Ubuntu, but not on Windows.
The exception was correct: the directory was gone. But this exception shows on the console. I would like to catch it. How to catch this exception in my application?
Any information would be appreciated. Thanks in advance.