MCPcopy Create free account
hub / github.com/e2wugui/zeze / main

Method main

ZezeJava/ZezeJavaTest/src/TestLog4jQuery/TestWatch.java:10–27  ·  view source on GitHub ↗
(String [] args)

Source from the content-addressed store, hash-verified

8
9public class TestWatch {
10 public static void main(String [] args) throws Exception {
11 var watchService = FileSystems.getDefault().newWatchService();
12 var directory = Paths.get(".");
13 directory.register(watchService, StandardWatchEventKinds.ENTRY_CREATE);
14 while (true) {
15 var key = watchService.take();
16 for (var event : key.pollEvents()) {
17 var kind = event.kind();
18 if (kind == StandardWatchEventKinds.ENTRY_CREATE) {
19 @SuppressWarnings("unchecked") WatchEvent<Path> renameEvent = (WatchEvent<Path>) event;
20 Path renamedFile = renameEvent.context();
21 System.out.println("Created: " + renamedFile);
22 }
23 }
24 if (!key.reset())
25 break;
26 }
27 }
28}

Callers

nothing calls this directly

Calls 4

contextMethod · 0.80
getMethod · 0.65
registerMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected