Files { public static final boolean removeFolder(final File folder) { if (folder == null) { return false; } if (folder.isDirectory()) { File[] files = folder.listFiles(); if (files != null) { for (File file : files) { if (file.isDirectory()) { removeFolder(file); } else { remove(file); } } } } return folder.delete(); } private  Files(); static String basePath(final String path, final String extension); static String extension(final String path); static String filename(final String path); static boolean remove(final File file); static final boolean removeFolder(final File folder); static final int writeTo(final File file, final InputStream input); static final int writeTo(final File file, final InputStream input,
                                    final int bufSize); static final String cleanupFilename(final String filename); static File getLocalFileFromUrl(URL url); static File getLocalFileFromUrl(String url); static Time getLastModified(File file); static boolean mkdirs(File folder);  }
@Test public void removeFolder() throws Exception { assertFalse("'null' folders are not deleted.", Files.removeFolder(null)); assertFalse("Non existing folders are not deleted.", Files.removeFolder(new File( "/somethingThatDoesntExistsOnMostMachines-111111111111111111111111111111"))); File folder = new File(System.getProperty("java.io.tmpdir"), "wicket-test-folder"); Files.mkdirs(folder); assertTrue(folder.isDirectory()); File file = new File(folder, "child"); file.createNewFile(); assertTrue(file.exists()); assertTrue("Should be able to delete a folder.", Files.removeFolder(folder)); }