public class FileContentsTransformer extends java.lang.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(java.lang.String path,
java.io.InputStream inputStream,
ContentsTransformer contentsTransformer,
boolean closeInputStream)
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. |
public FileContentsTransformer(ContentsTransformer contentsTransformer, boolean keepOriginals)
keepOriginals - Whether to keep a copy of the original file; only relevant for in-place transformationspublic void transform(java.lang.String path,
java.io.File in,
java.io.File out,
FileTransformer.Mode mode)
throws java.io.IOException
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.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.CHECKjava.io.IOExceptionFileTransformer.NOT_IDENTICAL,
FileTransformer.Mode.TRANSFORM,
FileTransformer.Mode.CHECK,
FileTransformer.Mode.CHECK_AND_TRANSFORMpublic static void checkIdentity(java.lang.String path,
java.io.InputStream inputStream,
ContentsTransformer contentsTransformer,
boolean closeInputStream)
throws java.io.IOException
inputStream and feeds it through the contentsTransformer.java.lang.RuntimeException - FileTransformer.NOT_IDENTICAL iff the transformer contents differs from the
original contentsjava.io.IOException