Skip to content

Commit 8518255

Browse files
committed
[IO-859] FileUtils.forceDelete on non-existent file on Windows throws
IOException rather than FileNotFoundException
1 parent 4c14c07 commit 8518255

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/org/apache/commons/io/file/PathUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ public static PathCounters deleteDirectory(final Path directory, final LinkOptio
524524
* @param file The file to delete.
525525
* @return A visitor with path counts set to 1 file, 0 directories, and the size of the deleted file.
526526
* @throws IOException if an I/O error occurs.
527-
* @throws NoSuchFileException if the file is a directory.
527+
* @throws NoSuchFileException if the file is a directory
528528
*/
529529
public static PathCounters deleteFile(final Path file) throws IOException {
530530
return deleteFile(file, EMPTY_DELETE_OPTION_ARRAY);
@@ -561,7 +561,7 @@ public static PathCounters deleteFile(final Path file, final LinkOption[] linkOp
561561
//
562562
// TODO Needs clean up?
563563
//
564-
if (!Files.exists(file, linkOptions) || Files.isDirectory(file, linkOptions)) {
564+
if (Files.isDirectory(file, linkOptions)) {
565565
throw new NoSuchFileException(file.toString());
566566
}
567567
final PathCounters pathCounts = Counters.longPathCounters();

0 commit comments

Comments
 (0)