Here you can find the source of deleteFile(String filePath)
public static void deleteFile(String filePath)
//License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.net.URL; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.util.regex.Pattern; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class Main{ public static void deleteFile(String filePath) { if (StringUtil.isEmpty(filePath)) { return; }/*from w w w . ja va 2 s .co m*/ File file = new File(filePath); if (!file.exists()) { return; } if (file.isDirectory()) { for (File tempFile : file.listFiles()) { deleteFile(tempFile.getPath()); } } file.delete(); } }