Package org.cactoos.io
Class HeadInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.cactoos.io.HeadInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public final class HeadInputStream extends InputStream
Input stream that only shows the first N bytes of the original stream.There is no thread-safety guarantee.
- Since:
- 0.31
-
-
Constructor Summary
Constructors Constructor Description HeadInputStream(InputStream orig, int len)
Ctor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
void
close()
void
mark(int readlimit)
boolean
markSupported()
int
read()
void
reset()
long
skip(long skip)
-
Methods inherited from class java.io.InputStream
nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
HeadInputStream
public HeadInputStream(InputStream orig, int len)
Ctor.- Parameters:
orig
- The original input stream.len
- A number of bytes that can be read from the beginning.
-
-
Method Detail
-
read
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
skip
public long skip(long skip) throws IOException
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
reset
public void reset() throws IOException
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
available
public int available() throws IOException
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classInputStream
-
mark
public void mark(int readlimit)
- Overrides:
mark
in classInputStream
-
-