@Test public void test() { File file = new File("./" + SnowflakeId.defaultNextId()); Path path = Paths.get(".", SnowflakeId.defaultNextId() + ""); try (FileCleaner cleaner = new FileCleaner()) { FileUtils.touch(file); assertTrue(file.exists()); cleaner.track(file); FileUtils.touch(path); assertTrue(path.toFile().exists()); cleaner.track(path); } assertFalse(file.exists()); assertFalse(path.toFile().exists()); }
public void track(File file) { if (file != null) { deque.add(file); } }
FileCleaner implements AutoCloseable { public void track(File file) { if (file != null) { deque.add(file); } } }
FileCleaner implements AutoCloseable { public void track(File file) { if (file != null) { deque.add(file); } }  }
FileCleaner implements AutoCloseable { public void track(File file) { if (file != null) { deque.add(file); } }  void track(File file); void track(Path path); @Override void close(); }
FileCleaner implements AutoCloseable { public void track(File file) { if (file != null) { deque.add(file); } }  void track(File file); void track(Path path); @Override void close();  }