Here you can find the source of delFileIfExists(String path)
public static void delFileIfExists(String path) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; public class Main { public static void delFileIfExists(String path) throws IOException { File f = new File(path); if (f.exists()) { delFile(f);//ww w.j av a 2 s . c om } } public static boolean delFile(File file) throws IOException { try { file.delete(); return true; } catch (Exception e) { throw new IOException("Failed to delete the file:" + file.getAbsoluteFile(), e); } } }