2
我試圖使用WatchService監視遠程文件夾(java.nio.file。*)。一切工作正常本地文件夾。但是我無法弄清楚如何監控遠程共享。我可以通過憑證嗎?使用WatchService監視遠程共享文件夾(Windows/SMB)
(如果執行代碼的用戶必須安裝它的工作原理,以及共享的權利。)
這裏是我的代碼部分:
public void lunch() throws IOException {
boolean recursive = true;
Path dir = Paths.get("C:\\test");
new Watch(dir, recursive).processEvents();
}
public Watch(Path dir, boolean recursive) throws IOException {
this.watcher = FileSystems.getDefault().newWatchService();
this.keys = new HashMap<WatchKey,Path>();
this.recursive = recursive;
if (recursive) {
System.out.format("Scanning %s ...\n", dir);
registerAll(dir);
System.out.println("Done.");
} else {
register(dir);
}
}
乾杯, 斯蒂芬妮
你有沒有關於如何在遠程系統中實現監控的例子? – Ianthe 2018-02-22 02:57:46