Here you can find the source of remove(File file)
public static void remove(File file)
//package com.java2s; import java.io.File; public class Main { public static void remove(String filePath) { try {//from w ww . ja va2 s . co m File file = new File(filePath); remove(file); } catch (Exception e) { e.printStackTrace(); } } public static void remove(File file) { if (file != null) { if (!file.isDirectory()) { file.delete(); } else { String[] children = file.list(); int size = children.length; for (int i = 0; i < size; i++) { remove(new File(file, children[i])); } file.delete(); } } } }