public void delete() { if (delfile != null) { this.getInsertDB().delShareFile(this.delfile); String realpath = ServletActionContext.getRequest().getRealPath(inputPath); File file = new File(realpath + "\\" + delfile); if (file != null) { file.delete(); } } }
public static void deleteIfExists(File file) { if (file.exists()) file.delete(); }
public static void deleteDirectory(File f) throws IOException { if (f.isDirectory()) { for (File c : f.listFiles()) deleteDirectory(c); } if (!f.delete()) throw new FileNotFoundException("Failed to delete file: " + f); }