- java.lang.Object
-
- java.io.InputStream
-
- org.hsqldb.lib.CountdownInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public final class CountdownInputStream extends java.io.InputStreamCounts down from a specified value the number of bytes actually read from the wrapped InputStream.Returns minus one (-1) early from readXXX methods if the count down reaches zero (0) before the end of the wrapped InputStream is encountered.
This class is especially useful when a fixed number of bytes is to be read from an InputStream that is in turn to be used as the source for an
InputStreamReader.- Since:
- 1.9.0
- Author:
- Campbell Burnet (campbell-burnet@users dot sourceforge.net)
-
-
Constructor Summary
Constructors Constructor Description CountdownInputStream(java.io.InputStream is)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()longgetCount()intread()intread(byte[] buf)intread(byte[] buf, int off, int len)voidsetCount(long count)longskip(long count)
-
-
-
Method Detail
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] buf) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] buf, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
skip
public long skip(long count) throws java.io.IOException- Overrides:
skipin classjava.io.InputStream- Throws:
java.io.IOException
-
getCount
public long getCount()
-
setCount
public void setCount(long count)
-
-