Here you can find the source of deletePath(final File path)
public static void deletePath(final File path) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static void deletePath(final File path) throws IOException { deletePathAndRetry(path, 3);/*from w w w . j a v a 2 s. c o m*/ } private static void deletePathAndRetry(final File path, final int retry) throws IOException { try { for (final String fn : path.list()) { final File f = new File(path, fn); if (f.isDirectory()) { deletePath(f); } if (!f.delete()) { throw new IOException( "Error cleaning up temporary resource. Failed to delete: " + f.getAbsolutePath()); } } } catch (IOException io) { if (retry > 0) { deletePathAndRetry(path, retry - 1); } else throw io; } } }