public class FileContentsTransformer extends Object implements FileTransformer
FileTransformer that transforms a file be feeding its contents through a ContentsTransformer.FileTransformer.ModeNOT_IDENTICAL, THROW_NOT_IDENTICAL| Constructor and Description |
|---|
FileContentsTransformer(ContentsTransformer contentsTransformer,
boolean keepOriginals) |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkIdentity(String path,
InputStream inputStream,
ContentsTransformer contentsTransformer,
boolean closeInputStream)
Consumes the inputStream, feeds it through the contentsTransformer, and checks whether
the output is identical with the input.
|
void |
transform(String path,
File in,
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. |
public FileContentsTransformer(ContentsTransformer contentsTransformer, boolean keepOriginals)
keepOriginals - Whether to keep a copy of the original file; only relevant for in-place transformationspublic void transform(String path, File in, File out, FileTransformer.Mode mode) throws IOException
ContentsTransformer, and writes it to the out file.transform in interface FileTransformerpath - A text designating the input file; typically, but not necessarily identical with in.getPath()in - The input file to readout - The output file to create; irrelevant iff mode == FileTransformer.Mode.CHECKIOExceptionFileTransformer.NOT_IDENTICAL,
FileTransformer.Mode.TRANSFORM,
FileTransformer.Mode.CHECK,
FileTransformer.Mode.CHECK_AND_TRANSFORMpublic static void checkIdentity(String path, InputStream inputStream, ContentsTransformer contentsTransformer, boolean closeInputStream) throws IOException
RuntimeException - FileTransformer.NOT_IDENTICAL iff the transformer contents differs from the
original contentsIOExceptionCopyright © 2018 Arno Unkrig. All rights reserved.