### Question:
FileUtils { public static IOStatus deleteDirectoryWithStatus(Path dir) throws IOException { if (!Files.exists(dir)) { IOStatus status = new IOStatus( ); status.addError( dir, new FileNotFoundException( "Directory not found " + dir ) ); return status; } if (!Files.isDirectory(dir)) { IOStatus status = new IOStatus( ); status.addError(dir, new IOException("Given path is not a directory " + dir)); } try( Stream<Path> stream = Files.walk(dir)) { return stream .sorted( Comparator.reverseOrder() ) .map(file -> { try { Files.delete(file); return new FileStatus( file, StatusResult.DELETED ); } catch (UncheckedIOException e) { log.warn("File could not be deleted {}", file); return new FileStatus( file, e.getCause( ) ); } catch ( IOException e ) { return new FileStatus( file, e ); } }).collect( IOStatus::new, IOStatus::accumulate, IOStatus::combine ); } catch (UncheckedIOException e) { throw new IOException("File deletion failed ", e); } }  static void deleteQuietly(Path dir); static IOStatus deleteDirectoryWithStatus(Path dir); static void deleteDirectory(Path dir); static String readFileToString(Path file, Charset encoding); static void writeStringToFile(Path file, Charset encoding, String value); static String getBasedir(); Path resolveNonAbsolute(Path parent, String child); static void unzipFileEntry(ZipFile file, ZipEntry entry, Path destinationPath); static void unzip(Path zipFile, Path destinationPath);  }### Answer:
@Test public void testDeleteWithStatus() throws IOException { Path td = Files.createTempDirectory( "FileUtilsTest" ); Path f1 = td.resolve("file1.txt"); Path f2 = td.resolve("file2.txt"); Path d1 = td.resolve("dir1"); Files.createDirectory( d1 ); Path d11 = d1.resolve("dir11"); Files.createDirectory( d11 ); Path f111 = d11.resolve("file111.txt"); Path f112 = d11.resolve("file112.txt"); Files.write(f1,"file1".getBytes()); Files.write(f2, "file2".getBytes()); Files.write(f111, "file111".getBytes()); Files.write(f112, "file112".getBytes()); assertTrue(Files.exists(d1)); assertTrue(Files.exists(f1)); assertTrue(Files.exists(f2)); assertTrue(Files.exists(f111)); assertTrue(Files.exists(f112)); IOStatus status = FileUtils.deleteDirectoryWithStatus( td ); assertFalse(Files.exists(f1)); assertFalse(Files.exists(f2)); assertFalse(Files.exists(f111)); assertFalse(Files.exists(f112)); assertFalse(Files.exists(d1)); assertTrue( status.isOk( ) ); assertFalse( status.hasErrors( ) ); assertEquals( 7, status.getSuccessFiles( ).size( ) ); assertEquals( 0, status.getErrorFiles( ).size() ); }