com.antelmann.io
Class ReplaceInputStream
java.lang.Object
java.io.InputStream
com.antelmann.io.InterceptInputStream
com.antelmann.io.ReplaceInputStream
- All Implemented Interfaces:
- InterceptInputStream.Handler, Closeable
public class ReplaceInputStream
- extends InterceptInputStream
- implements InterceptInputStream.Handler
This specialized stream replaces all occurrences of a given byte pattern with
another throughout the stream.
Also, this class can easily be overwritten to e.g. only replace only the first
or every second occurrence or the alike.
- Author:
- Holger Antelmann
|
Method Summary |
int |
getReplacementCount()
returns the number of replacements so far |
void |
patternFound(InterceptInputStream stream,
byte[] pattern)
only used internally (implementing InterceptInputStream.Handler);
skips the pattern length from the stream and inserts the replacementPattern |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ReplaceInputStream
public ReplaceInputStream(InputStream in,
byte[] searchPattern,
byte[] replacePattern)
getReplacementCount
public int getReplacementCount()
- returns the number of replacements so far
patternFound
public void patternFound(InterceptInputStream stream,
byte[] pattern)
throws IOException
- only used internally (implementing InterceptInputStream.Handler);
skips the pattern length from the stream and inserts the replacementPattern
- Specified by:
patternFound in interface InterceptInputStream.Handler
- Throws:
IOException
(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads