org.mycore.datamodel.ifs
Class MCRBlockingInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.io.BufferedInputStream
org.mycore.datamodel.ifs.MCRBlockingInputStream
- All Implemented Interfaces:
- Closeable
public class MCRBlockingInputStream
- extends BufferedInputStream
This class implements a special kind of BufferedInputStream that blocks
invocations of the read method until the number of bytes that were requested
are fully read from the underlying InputStream. In contrast,
BufferedInputStream does NOT block when the requested number of bytes is not
available yet.
- Version:
- $Revision: 13085 $ $Date: 2008-02-06 18:27:24 +0100 (Mi, 06 Feb 2008) $
- Author:
- Frank Lützenkirchen
- See Also:
BufferedInputStream
|
Method Summary |
int |
read(byte[] buf,
int off,
int len)
Reads 'len' bytes from the underlying input stream and writes the bytes
that have been read to the buffer 'buf', starting at offset 'off' in the
buffer byte array. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MCRBlockingInputStream
public MCRBlockingInputStream(InputStream in)
- Constructs a new MCRBlockingInputStream, using the default buffer size of
BufferedInputStreams.
- Parameters:
in - the InputStream to read data from
MCRBlockingInputStream
public MCRBlockingInputStream(InputStream in,
int size)
- Constructs a new MCRBlockingInputStream that uses the given buffer size.
- Parameters:
in - the InputStream to read data fromsize - the size of the read buffer to be used
read
public int read(byte[] buf,
int off,
int len)
throws IOException
- Reads 'len' bytes from the underlying input stream and writes the bytes
that have been read to the buffer 'buf', starting at offset 'off' in the
buffer byte array. In contrast to BufferedInputStream.read(), this method
blocks the read request until 'len' bytes have been read completely or
the end of the input stream is reached.
- Overrides:
read in class BufferedInputStream
- Returns:
- the number of bytes read. If the end of the input stream is not
reached yet, this is always the same as the number of bytes
requested in the 'len' parameter.
- Throws:
IOException