@@ -2519,7 +2519,7 @@ public static long sizeOf(final File file) {
25192519 }
25202520
25212521 if (file .isDirectory ()) {
2522- return sizeOfDirectory (file );
2522+ return sizeOfDirectory0 (file ); // private method; expects directory
25232523 } else {
25242524 return file .length ();
25252525 }
@@ -2566,7 +2566,6 @@ public static BigInteger sizeOfAsBigInteger(final File file) {
25662566 * overflow occurs. See {@link #sizeOfDirectoryAsBigInteger(File)} for an alternative
25672567 * method that does not overflow.
25682568 *
2569- *
25702569 * @param directory
25712570 * directory to inspect, must not be {@code null}
25722571 * @return size of directory in bytes, 0 if directory is security restricted, a negative number when the real total
@@ -2576,7 +2575,11 @@ public static BigInteger sizeOfAsBigInteger(final File file) {
25762575 */
25772576 public static long sizeOfDirectory (final File directory ) {
25782577 checkDirectory (directory );
2578+ return sizeOfDirectory0 (directory );
2579+ }
25792580
2581+ // Private method, must be invoked will a directory parameter
2582+ private static long sizeOfDirectory0 (final File directory ) {
25802583 final File [] files = directory .listFiles ();
25812584 if (files == null ) { // null if security restricted
25822585 return 0L ;
@@ -2586,7 +2589,7 @@ public static long sizeOfDirectory(final File directory) {
25862589 for (final File file : files ) {
25872590 try {
25882591 if (!isSymlink (file )) {
2589- size += sizeOf (file );
2592+ size += sizeOf0 (file ); // internal method
25902593 if (size < 0 ) {
25912594 break ;
25922595 }
@@ -2599,6 +2602,15 @@ public static long sizeOfDirectory(final File directory) {
25992602 return size ;
26002603 }
26012604
2605+ // Internal method - does not check existence
2606+ private static long sizeOf0 (File file ) {
2607+ if (file .isDirectory ()) {
2608+ return sizeOfDirectory0 (file );
2609+ } else {
2610+ return file .length (); // will be 0 if file does not exist
2611+ }
2612+ }
2613+
26022614 /**
26032615 * Counts the size of a directory recursively (sum of the length of all files).
26042616 *
0 commit comments