()
| 37 | } |
| 38 | |
| 39 | public void delete() throws IOException { |
| 40 | File parent = file.getParentFile(); |
| 41 | if (!parent.exists() || !parent.isDirectory()) { |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | if (file.exists()) { |
| 46 | if (file.isDirectory()) { |
| 47 | try (Stream<Path> files = Files.walk(file.toPath())) { |
| 48 | files.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); |
| 49 | } |
| 50 | } else { |
| 51 | Files.delete(file.toPath()); |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | public boolean exists() { |
| 57 | return file.exists() && file.isFile(); |
no test coverage detected