Class Directories


  • public final class Directories
    extends java.lang.Object
    Utilities for working with directory Path objects.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int count​(java.nio.file.Path dir)
      Count the number of entries in a directory.
      static java.util.List<java.nio.file.Path> list​(java.nio.file.Path dir)
      Convenience method to return all paths in a SMALL directory.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • count

        @Nonnegative
        public static int count​(@Nonnull
                                java.nio.file.Path dir)
                         throws java.io.IOException
        Count the number of entries in a directory.
        Parameters:
        dir - directory to evaluate
        Returns:
        number of inodes under it.
        Throws:
        java.io.IOException
      • list

        @Nonnull
        public static java.util.List<java.nio.file.Path> list​(@Nonnull
                                                              java.nio.file.Path dir)
                                                       throws java.io.IOException
        Convenience method to return all paths in a SMALL directory.

        DO NOT USE THIS TO TRAVERSE LARGE (multi-thousand inode) DIRECTORIES!

        For starters you shouldn't be making directories that big at all, but if you did please use Files.newDirectoryStream(Path) directly in your code.

        Parameters:
        dir - directory to evaluate
        Returns:
        all files in that directory
        Throws:
        java.io.IOException