Class FileTreeViews


  • public class FileTreeViews
    extends java.lang.Object
    Provides static methods returning instances of the various view interfaces defined throughout this package.
    • Method Detail

      • cached

        public static DirectoryView cached​(java.nio.file.Path path,
                                           int depth,
                                           boolean followLinks)
                                    throws java.io.IOException
        Make a new DirectoryView that caches the file tree but has no data value associated with each value.
        Parameters:
        path - the path to monitor
        depth - sets how the limit for how deep to traverse the children of this directory
        followLinks - sets whether or not to treat symbolic links whose targets as directories or files
        Returns:
        a directory whose entries just contain the path itself.
        Throws:
        java.io.IOException - when an error is encountered traversing the directory.
      • getNio

        public static FileTreeView getNio​(boolean followLinks)
        Returns an instance of FileTreeView that uses only apis available in java.nio.file. This may be used on platforms for which there is no native implementation of FileTreeView.
        Parameters:
        followLinks - toggles whether or not to follow the targets of symbolic links to directories.
        Returns:
        an instance of FileTreeView.
      • getNative

        public static FileTreeView getNative​(boolean followLinks)
        Returns an instance of FileTreeView that uses native jni functions to improve performance compared to the FileTreeView returned by getNio(boolean).
        Parameters:
        followLinks - toggles whether or not to follow the targets of symbolic links to directories.
        Returns:
        an instance of FileTreeView.
      • getDefault

        public static FileTreeView getDefault​(boolean followLinks)
        Returns the default FileTreeView for the runtime platform. If a native implementation is present, it will be used. Otherwise, it will fall back to the java.nio.file based implementation.
        Parameters:
        followLinks - toggles whether or not to follow the targets of symbolic links to directories.
        Returns:
        an instance of FileTreeView.
      • list

        public static java.util.List<TypedPath> list​(java.nio.file.Path path,
                                                     int maxDepth,
                                                     Filter<? super TypedPath> filter)
                                              throws java.io.IOException
        List the contents of a path.
        Parameters:
        path - the path to list. If the path is a directory, return the children of this directory up to the maxDepth. If the path is a regular file and the maxDepth is -1, the path itself is returned. Otherwise an empty list is returned.
        maxDepth - the maximum depth of children to include in the results
        filter - only include paths accepted by this filter
        Returns:
        a List of TypedPath
        Throws:
        java.io.IOException - if the Path doesn't exist