Here you can find the source of delete(final String[] paths)
public static void delete(final String[] paths) throws IOException
//package com.java2s; //License from project: LGPL import java.io.*; import java.nio.file.*; import java.nio.file.attribute.BasicFileAttributes; public class Main { public static void delete(final String[] paths) throws IOException { for (final String path : paths) { delete(path);// w ww .j a v a 2 s . c o m } } public static void delete(final String path) throws IOException { final File file = new File(path); if (file.exists()) { if (file.isFile()) { file.delete(); } else { final Path root = Paths.get(path); Files.walkFileTree(root, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException { Files.delete(file); return FileVisitResult.CONTINUE; } @Override public FileVisitResult preVisitDirectory(final Path file, final BasicFileAttributes attrs) throws IOException { if (!file.toString().equalsIgnoreCase(root.toString())) { delete(file.toString()); } return FileVisitResult.CONTINUE; } }); try { file.delete(); } catch (Throwable ignored) { } } } } public static boolean exists(final String fileName) { return (new File(fileName)).exists(); } }