@@ -285,17 +285,19 @@ public static String byteCountToDisplaySize(final Number size) {
285285 }
286286
287287 /**
288- * Requires that the given {@link File} object
289- * points to an actual file (not a directory) in the file system,
290- * and throws a {@link FileNotFoundException} if it doesn't.
291- * It throws an IllegalArgumentException if the object points to a directory.
288+ * Requires that the given {@link File} exists, and throws a {@link FileNotFoundException} if it doesn't.
292289 *
293290 * @param file The {@link File} to check.
294- * @param name The parameter name to use in the exception message.
295291 * @throws FileNotFoundException if the file does not exist
296- * @throws NullPointerException if the given {@link File} is {@code null}.
297- * @throws IllegalArgumentException if the given {@link File} is not a file.
292+ * @throws NullPointerException if the given {@link File} is {@code null}.
298293 */
294+ private static void checkExists (final File file ) throws FileNotFoundException {
295+ Objects .requireNonNull (file , "file" );
296+ if (!file .exists ()) {
297+ throw new FileNotFoundException (file .toString ());
298+ }
299+ }
300+
299301 private static void checkFileExists (final File file , final String name ) throws FileNotFoundException {
300302 Objects .requireNonNull (file , name );
301303 if (!file .isFile ()) {
@@ -1385,7 +1387,7 @@ private static void doCopyDirectory(final File srcDir, final File destDir, final
13851387 */
13861388 public static void forceDelete (final File file ) throws IOException {
13871389 Objects .requireNonNull (file , PROTOCOL_FILE );
1388- checkFileExists (file , file . getName () ); // fail-fast
1390+ checkExists (file ); // fail-fast
13891391 final Counters .PathCounters deleteCounters ;
13901392 try {
13911393 deleteCounters = PathUtils .delete (file .toPath (), PathUtils .EMPTY_LINK_OPTION_ARRAY , StandardDeleteOption .OVERRIDE_READ_ONLY );
0 commit comments