### Question:
Directory implements Serializable { public void deleteContents() throws DirectoryException { final File[] deleteList = listContents(s_matchAllFilesFilter, true, true); for (int i = deleteList.length - 1; i >= 0; --i) { if (deleteList[i].equals(getFile())) { continue; } if (!deleteList[i].delete()) { throw new DirectoryException( "Could not delete '" + deleteList[i] + "'"); } } } Directory();  Directory(final File directory); static FileFilter getMatchAllFilesFilter(); void create(); File getFile(); File getFile(final File child); File[] listContents(final FileFilter filter); File[] listContents(final FileFilter filter,
                             final boolean includeDirectories,
                             final boolean absolutePaths); void deleteContents(); void delete(); File rebaseFromCWD(final File file); File relativeFile(final File file, final boolean mustBeChild); List<File> rebasePath(final String path); boolean isParentOf(final File file); void copyTo(final Directory target, final boolean incremental); String[] getWarnings(); @Override int hashCode(); @Override boolean equals(final Object o);  }### Answer:
@Test public void testDeleteContents() throws Exception { final Directory directory = new Directory(getDirectory()); final String[] files = { "directory/foo/bah/blah", "directory/blah", "a/b/c/d/e", "a/b/f/g/h", "a/b/f/g/i", "x", "y/z", "another", }; for (final String file2 : files) { final File file = new File(getDirectory(), file2); file.getParentFile().mkdirs(); assertTrue(file.createNewFile()); } assertTrue(getDirectory().list().length > 0); directory.deleteContents(); assertEquals(0, getDirectory().list().length); }