Here you can find the source of delete(File f)
Parameter | Description |
---|---|
f | the file to delete |
Parameter | Description |
---|---|
IOException | if the file can't be deleted. |
private static void delete(File f) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; public class Main { /**/*from w ww.ja v a 2s . c o m*/ * Delete a file. This method will retry the delete up to 5 times, sleeping for one second between retries. * This is because sometimes, especially with smaller imports, the cleanup starts happening before vault has closed * all of it's file locks. The retry behavior makes a best effort to properly cleanup when that happens. * @param f the file to delete * @throws IOException if the file can't be deleted. */ private static void delete(File f) throws IOException { boolean isDeleted = f.delete(); for (int i = 0; i < 4 && !isDeleted; i++) { try { Thread.sleep(1000); } catch (InterruptedException e) { throw new IOException("Failed to delete file: " + f, e); } isDeleted = f.delete(); } if (!isDeleted) { throw new IOException("Failed to delete file: " + f); } } }