/** * Counts the size of a directory recursively (sum of the length of all files). * * @param directory directory to inspect, must not be {@code null} * @return size of directory in bytes, 0 if directory is security restricted. * @throws NullPointerException if the directory is {@code null} * @since 2.4 */ public static BigInteger sizeOfDirectoryAsBigInteger(final File directory) { checkDirectory(directory); return sizeOfDirectoryBig0(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); }
/** * Counts the size of a directory recursively (sum of the length of all files). * * @param directory directory to inspect, must not be {@code null} * @return size of directory in bytes, 0 if directory is security restricted. * @throws NullPointerException if the directory is {@code null} * @since 2.4 */ public static BigInteger sizeOfDirectoryAsBigInteger(final File directory) { checkDirectory(directory); return sizeOfDirectoryBig0(directory); }
/** * Counts the size of a directory recursively (sum of the length of all files). * * @param directory directory to inspect, must not be {@code null} * @return size of directory in bytes, 0 if directory is security restricted. * @throws NullPointerException if the directory is {@code null} * @since 2.4 */ public static BigInteger sizeOfDirectoryAsBigInteger(final File directory) { checkDirectory(directory); return sizeOfDirectoryBig0(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); }
/** * 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). * * @param directory * directory to inspect, must not be {@code null} * @return size of directory in bytes, 0 if directory is security restricted. * @throws NullPointerException * if the directory is {@code null} * @since 2.4 */ public static BigInteger sizeOfDirectoryAsBigInteger(File directory) { checkDirectory(directory); final File[] files = directory.listFiles(); if (files == null) { // null if security restricted return BigInteger.ZERO; } BigInteger size = BigInteger.ZERO; for (final File file : files) { try { if (!isSymlink(file)) { size = size.add(BigInteger.valueOf(sizeOf(file))); } } catch (IOException ioe) { // Ignore exceptions caught when asking if a File is a symlink. } } return size; }