FileUtils { public static boolean delete(File file) { if (!file.exists()) { return true; } if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null) { for (File c : files) { delete(c); } } } return file.delete(); } private  FileUtils(); static boolean contains(File[] files, String fileName); static int getAmountOfFiles(File directory); static String getContentOfFile(File file); static String[] getContentAsLines(File file); static Collection<File> findFilesByExtension(String directory, String extension); static Collection<File> findFilesByExtension(File directory, String extension); static Node<File> collectFiles(File directory); static void overrideFile(File file, String content); static boolean delete(File file); static File[] toFiles(String... paths); static String getName(File file); static String getName(URL url); static String getName(String path);  }
@Test void delete() throws IOException { File d = new File(directory, "d"); Assertions.assertTrue(d.createNewFile()); Assertions.assertEquals(5, FileUtils.getAmountOfFiles(directory)); Assertions.assertTrue(FileUtils.delete(d)); Assertions.assertEquals(4, FileUtils.getAmountOfFiles(directory)); }