Package org.apache.poi.util
Class ReplacingInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.apache.poi.util.ReplacingInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
Simple FilterInputStream that can replace occurrences of bytes with something else.
This has been taken from inbot-utils. (MIT licensed)
- See Also:
-
Field Summary
Fields inherited from class java.io.FilterInputStream
in -
Constructor Summary
ConstructorsConstructorDescriptionReplacingInputStream(InputStream in, byte[] pattern, byte[] replacement) Replace occurrences of pattern in the input.ReplacingInputStream(InputStream in, String pattern, String replacement) Replace occurrences of pattern in the input. -
Method Summary
Modifier and TypeMethodDescriptionvoidmark(int readlimit) booleanMarking is not supported, as the match state can't be restoredintread()intread(byte[] b) intread(byte[] b, int off, int len) voidreset()longskip(long n) Skips by reading, so that the skipped bytes go through the replacementtoString()Methods inherited from class java.io.FilterInputStream
available, closeMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
ReplacingInputStream
Replace occurrences of pattern in the input. Note: input is assumed to be UTF-8 encoded. If not the case use byte[] based pattern and replacement.- Parameters:
in- inputpattern- pattern to replace.replacement- the replacement or null
-
ReplacingInputStream
Replace occurrences of pattern in the input.If you want to normalize line endings DOS/MAC (\n\r | \r) to UNIX (\n), you can call the following:
new ReplacingInputStream(new ReplacingInputStream(is, "\n\r", "\n"), "\r", "\n")- Parameters:
in- inputpattern- pattern to replacereplacement- the replacement or null
-
-
Method Details
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
- Overrides:
readin classFilterInputStream- Throws:
IOException
-
skip
Skips by reading, so that the skipped bytes go through the replacement- Overrides:
skipin classFilterInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()Marking is not supported, as the match state can't be restored- Overrides:
markSupportedin classFilterInputStream
-
mark
public void mark(int readlimit) - Overrides:
markin classFilterInputStream
-
reset
- Overrides:
resetin classFilterInputStream- Throws:
IOException
-
toString
-