Here you can find the source of deleteFileAndFolder(File fileOrFolder)
private static void deleteFileAndFolder(File fileOrFolder)
//package com.java2s; import java.io.File; public class Main { private static void deleteFileAndFolder(File fileOrFolder) { if (fileOrFolder == null || !fileOrFolder.exists()) { return; }/* w w w . j a va2s. com*/ if (fileOrFolder.isDirectory()) { File[] children = fileOrFolder.listFiles(); if (children != null) { for (File childFile : children) { deleteFileAndFolder(childFile); } } } else { fileOrFolder.delete(); } } }