Here you can find the source of safelyDeleteFile(File filePath)
public static void safelyDeleteFile(File filePath)
//package com.java2s; import java.io.File; public class Main { public static void safelyDeleteFile(String filePath) { safelyDeleteFile(new File(filePath)); }//from ww w .j ava 2 s . com public static void safelyDeleteFile(File filePath) { if (filePath != null && filePath.exists()) { filePath.delete(); } } }