![](/img/trans.png)
[英]Java watchservice, how to find the directory where the file was created?
[英]java file system WatchService not picking up file when file is created by another java programm
我已经在文件系统目录上实现了WatchService。 还有另一个Java进程写入该目录。 当我在目录中手动创建文件时,WatchService可以接收该文件,但是当另一个Java进程在该目录中创建文件时,WatchService则无法接收该文件。 我正在使用下面的示例代码来写入文件。
com.google.common.io.Files.write("test content".getBytes(), new File("/var/tmp/dir/1.txt"));
问题出在已挂载的NFS文件系统上。 必须使用Apache File Watcher API来解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.