com.sibvisions.util.io
Class MagicByteInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
com.sibvisions.util.io.MagicByteInputStream
- All Implemented Interfaces:
- Closeable
public class MagicByteInputStream
- extends FilterInputStream
The MagicByteInputStream is an InputStream wrapper which reads some magic
bytes from the end of the stream. It will read the byte sequence until found.
|
Constructor Summary |
MagicByteInputStream(InputStream pStream,
byte[] pMagic)
Creates a new instance of MagicByteInputStream for the given stream
and magic byte(s). |
|
Method Summary |
void |
close()
|
int |
read()
|
int |
read(byte[] pContent,
int pOffset,
int pLength)
|
void |
readMagicByte()
Reads until the magic byte was found. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MagicByteInputStream
public MagicByteInputStream(InputStream pStream,
byte[] pMagic)
- Creates a new instance of
MagicByteInputStream for the given stream
and magic byte(s).
- Parameters:
pStream - the wrapped streampMagic - the magic byte sequence
read
public int read()
throws IOException
-
- Overrides:
read in class FilterInputStream
- Throws:
IOException
read
public int read(byte[] pContent,
int pOffset,
int pLength)
throws IOException
-
- Overrides:
read in class FilterInputStream
- Throws:
IOException
close
public void close()
throws IOException
-
- Specified by:
close in interface Closeable- Overrides:
close in class FilterInputStream
- Throws:
IOException
readMagicByte
public void readMagicByte()
throws IOException
- Reads until the magic byte was found.
- Throws:
IOException - if reading failed or EOF reached and magic byte wasn't found
Copyright © 2009 SIB Visions GmbH. All Rights Reserved.