de.unkrig.commons.file.filetransformation
Class FileContentsTransformer
java.lang.Object
de.unkrig.commons.file.filetransformation.FileContentsTransformer
- All Implemented Interfaces:
- FileTransformer
public class FileContentsTransformer
- extends java.lang.Object
- implements FileTransformer
A FileTransformer that transforms a file be feeding its contents through a ContentsTransformer.
|
Method Summary |
static void |
checkIdentity(java.lang.String path,
java.io.InputStream inputStream,
ContentsTransformer contentsTransformer)
Consumes the inputStream and feeds it through the contentsTransformer. |
void |
transform(java.lang.String path,
java.io.File in,
java.io.File out,
FileTransformer.Mode mode)
Opens the in file for reading, opens the out file for writing, reads the contents, feeds it
through the given ContentsTransformer, and writes it to the out file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileContentsTransformer
public FileContentsTransformer(ContentsTransformer contentsTransformer,
boolean keepOriginals)
transform
public void transform(java.lang.String path,
java.io.File in,
java.io.File out,
FileTransformer.Mode mode)
throws java.io.IOException
- Opens the
in file for reading, opens the out file for writing, reads the contents, feeds it
through the given ContentsTransformer, and writes it to the out file.
- Specified by:
transform in interface FileTransformer
- Parameters:
path - A text designating the input file; typically, but not necessarily identical with in.getPath()
- Throws:
java.io.IOException- See Also:
FileTransformer.NOT_IDENTICAL,
FileTransformer.Mode.TRANSFORM,
FileTransformer.Mode.CHECK,
FileTransformer.Mode.CHECK_AND_TRANSFORM
checkIdentity
public static void checkIdentity(java.lang.String path,
java.io.InputStream inputStream,
ContentsTransformer contentsTransformer)
throws java.io.IOException
- Consumes the
inputStream and feeds it through the contentsTransformer.
- Throws:
java.lang.RuntimeException - FileTransformer.NOT_IDENTICAL iff the transformer contents differs from the
original contents
java.io.IOException