public static void anotherWatcher() {
        try {
            WatchService watchService = FileSystems.getDefault().newWatchService();
            Path dir = Paths.get("/home/xander/test/");

            dir.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY);
            FileTime lastModified = null;

            while (true) {
                WatchKey key = watchService.take();
                for (WatchEvent<?> event : key.pollEvents()) {
                    if (event.kind() == StandardWatchEventKinds.ENTRY_MODIFY) {
                        FileTime time = Files.getLastModifiedTime(dir.resolve(Paths.get("file.txt")));
                        if (lastModified == null) {
                            lastModified = time;
                        }
                        if (lastModified.compareTo(time) < 0) {
                            System.out.println("reload");
                            lastModified = time;
                            Calendar date = Calendar.getInstance();
                            date.setTimeInMillis(time.toMillis());
                            System.out.println("time is " + date.getTime() + "\n");
                        } else {
                            System.out.println("reload skipped");
                        }
                    }
                }
                key.reset();
            }
        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }
    }