@Test public void testDelete() throws Exception { Files.createDirectories(path("a", "b", "c")); Files.createDirectories(path("a", "b1")); Files.createDirectories(path("a", "b", "c1")); Files.createFile(path("a", "x")); Files.createFile(path("a", "b", "x")); Files.createFile(path("a", "b1", "x")); Files.createFile(path("a", "b", "c", "x")); Files.createFile(path("a", "b", "c1", "x")); assertTrue(Files.exists(path("a"))); assertTrue(Files.isDirectory(path("a"))); Capsule.delete(path("a")); assertTrue(!Files.exists(path("a"))); }
static void delete(Path path) throws IOException { log(LOG_DEBUG, "Deleting " + path); if (!Files.exists(path)) return; if (Files.isDirectory(path)) { try (DirectoryStream<Path> ds = Files.newDirectoryStream(path)) { for (Path f : ds) delete(f); } } Files.delete(path); }
Capsule implements Runnable, InvocationHandler { static void delete(Path path) throws IOException { log(LOG_DEBUG, "Deleting " + path); if (!Files.exists(path)) return; if (Files.isDirectory(path)) { try (DirectoryStream<Path> ds = Files.newDirectoryStream(path)) { for (Path f : ds) delete(f); } } Files.delete(path); } }
Capsule implements Runnable, InvocationHandler { static void delete(Path path) throws IOException { log(LOG_DEBUG, "Deleting " + path); if (!Files.exists(path)) return; if (Files.isDirectory(path)) { try (DirectoryStream<Path> ds = Files.newDirectoryStream(path)) { for (Path f : ds) delete(f); } } Files.delete(path); } @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) protected  Capsule(Path jarFile); @SuppressWarnings("LeakingThisInConstructor") protected  Capsule(Capsule pred); }
Capsule implements Runnable, InvocationHandler { static void delete(Path path) throws IOException { log(LOG_DEBUG, "Deleting " + path); if (!Files.exists(path)) return; if (Files.isDirectory(path)) { try (DirectoryStream<Path> ds = Files.newDirectoryStream(path)) { for (Path f : ds) delete(f); } } Files.delete(path); } @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) protected  Capsule(Path jarFile); @SuppressWarnings("LeakingThisInConstructor") protected  Capsule(Capsule pred); static final void main(String[] args); @SuppressWarnings({"BroadCatchBlock", "UnusedAssignment"}) static int main0(String[] args0); static void premain(String agentArgs, Instrumentation inst); static Object getCapsule(String capletClassName); boolean isAgent(); @Override final void run(); @Override Object invoke(Object proxy, Method method, Object[] args); @Override final int hashCode(); @Override final boolean equals(Object obj); @Override String toString(); }
Capsule implements Runnable, InvocationHandler { static void delete(Path path) throws IOException { log(LOG_DEBUG, "Deleting " + path); if (!Files.exists(path)) return; if (Files.isDirectory(path)) { try (DirectoryStream<Path> ds = Files.newDirectoryStream(path)) { for (Path f : ds) delete(f); } } Files.delete(path); } @SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) protected  Capsule(Path jarFile); @SuppressWarnings("LeakingThisInConstructor") protected  Capsule(Capsule pred); static final void main(String[] args); @SuppressWarnings({"BroadCatchBlock", "UnusedAssignment"}) static int main0(String[] args0); static void premain(String agentArgs, Instrumentation inst); static Object getCapsule(String capletClassName); boolean isAgent(); @Override final void run(); @Override Object invoke(Object proxy, Method method, Object[] args); @Override final int hashCode(); @Override final boolean equals(Object obj); @Override String toString(); static final String VERSION; }