Package edu.stanford.nlp.util
Class FilePathProcessor
- java.lang.Object
-
- edu.stanford.nlp.util.FilePathProcessor
-
public class FilePathProcessor extends Object
TheFilePathProcessortraverses a directory structure and applies theprocessFilemethod to files meeting some criterion. It is implemented as static methods, not as an extension ofFile.Note: This is used in our old code in ling/trees, but newer code should probably use io.FileSequentialCollection
- Author:
- Christopher Manning
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidprocessPath(File path, FileFilter filter, FileProcessor processor)Apply a function to the files under a given directory and perhaps its subdirectories.static voidprocessPath(File path, String suffix, boolean recursively, FileProcessor processor)Apply a method to the files under a given directory and perhaps its subdirectories.static voidprocessPath(String pathStr, String suffix, boolean recursively, FileProcessor processor)Apply a method to the files under a given directory and perhaps its subdirectories.
-
-
-
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 Stringsuffix- suffix (normally "File extension") of files to loadrecursively- true means descend into subdirectories as wellprocessor- TheFileProcessorto apply to eachFile
-
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 fromsuffix- suffix (normally "File extension") of files to loadrecursively- true means descend into subdirectories as wellprocessor- TheFileProcessorto apply to eachFile
-
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 thepathis 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 aFileFilter.)- Parameters:
path- file or directory to load fromfilter- a FileFilter of files to load. The filter may be null, and then all files are processed.processor- TheFileProcessorto apply to eachFile
-
-