Java tutorial
//package com.java2s; import java.io.File; public class Main { public static void deleteFile(File file) { try { if (file != null && file.isFile() && file.exists()) { file.delete(); } } catch (Exception e) { e.printStackTrace(); } } public static void deleteFile(String path) { try { File file = new File(path); if (file.exists()) { file.delete(); } } catch (Exception e) { e.printStackTrace(); } } }