Here you can find the source of deleteFile(String filename)
public static void deleteFile(String filename)
//package com.java2s; import java.io.*; public class Main { public static void deleteFile(String filename) { deleteFile(new File(filename)); }// w w w . ja v a 2 s . c o m public static void deleteFile(File file) { if (!file.exists()) return; if (!file.delete()) throw new RuntimeException("Could not delete '" + file.getAbsoluteFile() + "'"); waitUntilFileDeleted(file); } private static void waitUntilFileDeleted(File file) { int i = 10; while (file.exists()) { if (--i <= 0) { System.out.println("Breaking out of delete wait"); break; } try { Thread.sleep(500); } catch (InterruptedException e) { } } } }