Here you can find the source of deleteAll(File f)
public static void deleteAll(File f)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; public class Main { public static void deleteAll(File f) { Path start = FileSystems.getDefault().getPath(f.getAbsolutePath()); try {/*ww w.ja va2s. c om*/ Files.walkFileTree(start, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.delete(file); return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException e) throws IOException { if (e == null) { Files.delete(dir); return FileVisitResult.CONTINUE; } else { // directory iteration failed throw e; } } }); } catch (IOException e) { e.printStackTrace(); } } }