ides.api.utilities
Class HeadTailInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
ides.api.utilities.HeadTailInputStream
- All Implemented Interfaces:
- java.io.Closeable
public class HeadTailInputStream
- extends java.io.FilterInputStream
Wrapper for InputStreams which allows the prefixing of the stream
with a header and the appending of a tail to the stream. To the reader of the
stream, it appears as if the stream contains the header, the content of the
original stream and the tail.
For example, if one wants to add the tags "<b>" and "</b>" around
the content of the stream input, it is sufficient to say:
input=new HeadTailInputStream(input,"<b>".getBytes(),"</b>".getBytes());
- Author:
- Lenko Grigorov
|
Field Summary |
protected byte[] |
head
The header to be available before the content of the original stream. |
protected byte[] |
tail
The tail to be available after the content of the original stream. |
| Fields inherited from class java.io.FilterInputStream |
in |
|
Constructor Summary |
HeadTailInputStream(java.io.InputStream in,
byte[] head,
byte[] tail)
Wrap an InputStream so that readers read a custom header before
the original content and a custom tail after the original content. |
| Methods inherited from class java.io.FilterInputStream |
close, mark |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
head
protected byte[] head
- The header to be available before the content of the original stream.
tail
protected byte[] tail
- The tail to be available after the content of the original stream.
HeadTailInputStream
public HeadTailInputStream(java.io.InputStream in,
byte[] head,
byte[] tail)
- Wrap an
InputStream so that readers read a custom header before
the original content and a custom tail after the original content.
- Parameters:
in - the stream to be wrappedhead - the custom header to be available before the original contenttail - the custom tail to be available after the original content
available
public int available()
throws java.io.IOException
- Overrides:
available in class java.io.FilterInputStream
- Throws:
java.io.IOException
mark
public void mark()
reset
public void reset()
- Overrides:
reset in class java.io.FilterInputStream
markSupported
public boolean markSupported()
- Overrides:
markSupported in class java.io.FilterInputStream
skip
public long skip(long n)
throws java.io.IOException
- Overrides:
skip in class java.io.FilterInputStream
- Throws:
java.io.IOException
read
public int read()
throws java.io.IOException
- Overrides:
read in class java.io.FilterInputStream
- Throws:
java.io.IOException
read
public int read(byte[] b,
int off,
int len)
throws java.io.IOException
- Overrides:
read in class java.io.FilterInputStream
- Throws:
java.io.IOException
read
public int read(byte[] b)
throws java.io.IOException
- Overrides:
read in class java.io.FilterInputStream
- Throws:
java.io.IOException