public static void remove(final File file) { if (file == null) { return; } if (!file.exists()) { return; } if (file.isDirectory()) { final File[] files = file.listFiles(); if (files != null) { for (final File child : files) { remove(child); } } } if (!file.delete()) { throw new IllegalStateException("Could not delete file: " + file.getAbsolutePath()); } }
/** * Delete a file and all contents if specified file is a directory * * @param file File * @Throws IllegalStateException on failure at any point */ public static void remove(final File file) { if (null != file && file.exists()) { if (file.isDirectory()) { final File[] files = file.listFiles(); if (files != null) { for (final File child : files) { remove(child); } } } hackJDK4715154(); if (!file.delete()) { throw new IllegalStateException("Could not delete file: " + file.getAbsolutePath()); } } }
Files.remove(delete); break; } catch (final Exception e) {
Files.remove(delete); break; } catch (final Exception e) {