Here you can find the source of deleteFile(String fileName)
public static void deleteFile(String fileName)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static void deleteFile(String fileName) { deleteFile(new File(fileName)); }/* w w w. ja v a2 s . com*/ public static void deleteFile(File file) { if (file.exists()) delete(file); } public static boolean exists(String fileName) { return (new File(fileName)).exists(); } private static void delete(File file) { if (file.isDirectory()) { File[] files = file.listFiles(); for (File file2 : files) delete(file2); } if (!file.delete()) throw new RuntimeException("Failed to delete file: " + file); } }