de.unkrig.commons.file.fileprocessing
Class FileContentsProcessor<T>
java.lang.Object
de.unkrig.commons.file.fileprocessing.FileContentsProcessor<T>
- Type Parameters:
T - The type that process(String, File) returns; use "Void" if not needed
- All Implemented Interfaces:
- FileProcessor<T>
public class FileContentsProcessor<T>
- extends java.lang.Object
- implements FileProcessor<T>
Processes a file by opening the file, feeding its contents to the ContentsProcessor, and eventually closing
the file.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
contentsProcessor
protected final ContentsProcessor<T> contentsProcessor
- The
ContentsProcessor that is used to process a file's contents when process(String, File) is
invoked.
FileContentsProcessor
public FileContentsProcessor(ContentsProcessor<T> contentsProcessor)
process
@Nullable
public T process(java.lang.String path,
java.io.File file)
throws java.io.FileNotFoundException,
java.io.IOException
- Opens the
file, passes the input stream to ContentsProcessor.process(String, InputStream, long,
long, ProducerWhichThrows), then closes the file.
Subclasses may override this behavior, e.g. by recursing into directories or archives.
- Specified by:
process in interface FileProcessor<T>
- Parameters:
path - The string that characterizes the file
- Throws:
java.io.IOException - Message should include the file name
java.io.FileNotFoundException