Package pixy.io
Class PeekHeadInputStream
java.lang.Object
java.io.InputStream
pixy.io.PeekHeadInputStream
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class PeekHeadInputStream
extends java.io.InputStream
Lightweight stream wrapper which allows to peek a
fixed length of bytes from the current stream head
-
Constructor Summary
Constructors Constructor Description PeekHeadInputStream(java.io.InputStream src, int bytesToPeek)
-
Method Summary
Modifier and Type Method Description void
close()
byte[]
peek(int len)
int
read()
int
read(byte[] b, int off, int len)
void
shallowClose()
-
Constructor Details
-
PeekHeadInputStream
public PeekHeadInputStream(java.io.InputStream src, int bytesToPeek)- Parameters:
bytesToPeek
- number of bytes to peeksrc
- The source InputStream to use
-
-
Method Details
-
close
public void close() throws java.io.IOException- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
shallowClose
public void shallowClose() throws java.io.IOException- Throws:
java.io.IOException
-
peek
public byte[] peek(int len) throws java.io.IOException- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-