Class FilePathProcessor


  • public class FilePathProcessor
    extends Object
    The FilePathProcessor traverses a directory structure and applies the processFile method to files meeting some criterion. It is implemented as static methods, not as an extension of File.

    Note: This is used in our old code in ling/trees, but newer code should probably use io.FileSequentialCollection

    Author:
    Christopher Manning
    • Method Detail

      • processPath

        public static void processPath​(String pathStr,
                                       String suffix,
                                       boolean recursively,
                                       FileProcessor processor)
        Apply a method to the files under a given directory and perhaps its subdirectories.
        Parameters:
        pathStr - file or directory to load from as a String
        suffix - suffix (normally "File extension") of files to load
        recursively - true means descend into subdirectories as well
        processor - The FileProcessor to apply to each File
      • processPath

        public static void processPath​(File path,
                                       String suffix,
                                       boolean recursively,
                                       FileProcessor processor)
        Apply a method to the files under a given directory and perhaps its subdirectories.
        Parameters:
        path - file or directory to load from
        suffix - suffix (normally "File extension") of files to load
        recursively - true means descend into subdirectories as well
        processor - The FileProcessor to apply to each File
      • processPath

        public static void processPath​(File path,
                                       FileFilter filter,
                                       FileProcessor processor)
        Apply a function to the files under a given directory and perhaps its subdirectories. If the path is a directory then only files within the directory (perhaps recursively) that satisfy the filter are processed. If the pathis a file, then that file is processed regardless of whether it satisfies the filter. (This semantics was adopted, since otherwise there was no easy way to go through all the files in a directory without descending recursively via the specification of a FileFilter.)
        Parameters:
        path - file or directory to load from
        filter - a FileFilter of files to load. The filter may be null, and then all files are processed.
        processor - The FileProcessor to apply to each File