/** * the size of a file * @param file the file to check * @return the size of the file */ private static long sizeOf0(final File file) { if (file.isDirectory()) { return sizeOfDirectory0(file); } else { return file.length(); // will be 0 if file does not exist } }
/** * Counts the size of a directory recursively (sum of the length of all files). * <p> * Note that overflow is not detected, and the return value may be negative if * overflow occurs. See {@link #sizeOfDirectoryAsBigInteger(File)} for an alternative * method that does not overflow. * * @param directory directory to inspect, must not be {@code null} * @return size of directory in bytes, 0 if directory is security restricted, a negative number when the real total * is greater than {@link Long#MAX_VALUE}. * @throws NullPointerException if the directory is {@code null} */ public static long sizeOfDirectory(final File directory) { checkDirectory(directory); return sizeOfDirectory0(directory); }
return sizeOfDirectory0(file); // private method; expects directory } else { return file.length();
/** * the size of a file * @param file the file to check * @return the size of the fil */ private static long sizeOf0(File file) { if (file.isDirectory()) { return sizeOfDirectory0(file); } else { return file.length(); // will be 0 if file does not exist } }
/** * the size of a file * @param file the file to check * @return the size of the file */ private static long sizeOf0(final File file) { if (file.isDirectory()) { return sizeOfDirectory0(file); } else { return file.length(); // will be 0 if file does not exist } }
/** * Counts the size of a directory recursively (sum of the length of all files). * <p> * Note that overflow is not detected, and the return value may be negative if * overflow occurs. See {@link #sizeOfDirectoryAsBigInteger(File)} for an alternative * method that does not overflow. * * @param directory directory to inspect, must not be {@code null} * @return size of directory in bytes, 0 if directory is security restricted, a negative number when the real total * is greater than {@link Long#MAX_VALUE}. * @throws NullPointerException if the directory is {@code null} */ public static long sizeOfDirectory(final File directory) { checkDirectory(directory); return sizeOfDirectory0(directory); }
/** * Counts the size of a directory recursively (sum of the length of all files). * <p> * Note that overflow is not detected, and the return value may be negative if * overflow occurs. See {@link #sizeOfDirectoryAsBigInteger(File)} for an alternative * method that does not overflow. * * @param directory directory to inspect, must not be {@code null} * @return size of directory in bytes, 0 if directory is security restricted, a negative number when the real total * is greater than {@link Long#MAX_VALUE}. * @throws NullPointerException if the directory is {@code null} */ public static long sizeOfDirectory(final File directory) { checkDirectory(directory); return sizeOfDirectory0(directory); }
return sizeOfDirectory0(file); // private method; expects directory } else { return file.length();
return sizeOfDirectory0(file); // private method; expects directory } else { return file.length();