@Test public void testCleanDirectory() { File testChildren = new File(testParent, "this/is/a/test"); boolean success = testChildren.mkdirs(); assertTrue("Could not create test folder", success); FileUtils.cleanDirectory(testParent); assertTrue("Parent was deleted", testParent.exists()); assertEquals(0, testParent.list().length); }
public static void cleanDirectory(File directory) { boolean success; if (directory.isDirectory()) { String[] children = directory.list(); for (int i=0; i<children.length; i++) { File child = new File(directory, children[i]); if (child.isDirectory()) { success = deleteDirectory(child); } else { success = child.delete(); } if(!success){ } } } }
FileUtils { public static void cleanDirectory(File directory) { boolean success; if (directory.isDirectory()) { String[] children = directory.list(); for (int i=0; i<children.length; i++) { File child = new File(directory, children[i]); if (child.isDirectory()) { success = deleteDirectory(child); } else { success = child.delete(); } if(!success){ } } } } }
FileUtils { public static void cleanDirectory(File directory) { boolean success; if (directory.isDirectory()) { String[] children = directory.list(); for (int i=0; i<children.length; i++) { File child = new File(directory, children[i]); if (child.isDirectory()) { success = deleteDirectory(child); } else { success = child.delete(); } if(!success){ } } } } private  FileUtils(); }
FileUtils { public static void cleanDirectory(File directory) { boolean success; if (directory.isDirectory()) { String[] children = directory.list(); for (int i=0; i<children.length; i++) { File child = new File(directory, children[i]); if (child.isDirectory()) { success = deleteDirectory(child); } else { success = child.delete(); } if(!success){ } } } } private  FileUtils(); static File getFileFromPackage(File target, String pack); static void cleanDirectory(File directory); static boolean deleteDirectory(File directory); static void deleteFiles(File directory); static Object readObject(String fileName); static void writeObject(String fileName, Object o); static String getFileAsString(File file); static void writeStringToFile(File file, String contents); static void replaceAll(File file, String input, String output); static void close(Closeable closeable); }
FileUtils { public static void cleanDirectory(File directory) { boolean success; if (directory.isDirectory()) { String[] children = directory.list(); for (int i=0; i<children.length; i++) { File child = new File(directory, children[i]); if (child.isDirectory()) { success = deleteDirectory(child); } else { success = child.delete(); } if(!success){ } } } } private  FileUtils(); static File getFileFromPackage(File target, String pack); static void cleanDirectory(File directory); static boolean deleteDirectory(File directory); static void deleteFiles(File directory); static Object readObject(String fileName); static void writeObject(String fileName, Object o); static String getFileAsString(File file); static void writeStringToFile(File file, String contents); static void replaceAll(File file, String input, String output); static void close(Closeable closeable); static final String SEPARATOR; }