| | |
| | | public static boolean deleteFiles(Iterable<File> files) |
| | | { |
| | | boolean allDeleted = true; |
| | | if (files != null) |
| | | for (File f : files) |
| | | { |
| | | for (File f : files) |
| | | if (!f.isDirectory()) |
| | | { |
| | | if (!f.isDirectory()) |
| | | { |
| | | allDeleted = f.delete() && allDeleted; |
| | | } |
| | | allDeleted &= f.delete(); |
| | | } |
| | | } |
| | | return allDeleted; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the sorted list of names of provided files. |
| | | * |
| | | * @param files |
| | | * The files to sort and get the names of |
| | | * @return the sorted list of file names |
| | | */ |
| | | public static List<String> getFileNames(final File[] files) |
| | | { |
| | | final List<String> names = new ArrayList<>(files.length); |
| | | for (final File f : files) |
| | | { |
| | | if (f.isFile()) |
| | | { |
| | | names.add(f.getName()); |
| | | } |
| | | } |
| | | Collections.sort(names); |
| | | return names; |
| | | } |
| | | |
| | | /** |
| | | * Retrieves a {@code File} object corresponding to the specified path. |
| | | * If the given path is an absolute path, then it will be used. If the path |
| | | * is relative, then it will be interpreted as if it were relative to the |