public class BlockingInputStream extends InputStream
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buf
The transfer buffer
|
protected boolean |
closed
Set to true when
close() is called |
protected Lock |
lock |
protected Condition |
not_empty
Signalled when the buf becomes 'readable'; ie.
|
protected Condition |
not_full
Signalled when the buf becomes 'writeable'; ie.
|
protected int |
read_pos
Index into buf at which the next bytes will be read.
|
protected int |
write_pos
Index into buf at which bytes will be written.
|
| Constructor and Description |
|---|
BlockingInputStream() |
BlockingInputStream(int capacity) |
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
int |
capacity() |
void |
close()
Closes the stream.
|
protected void |
compact()
Moves the bytes between [read_pos and write_pos] read_pos bytes to the left, such that the new read_pos is 0
and the write_pos is write_pos - read_pos.
|
boolean |
isClosed() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
protected int |
remaining() |
protected static void |
sanityCheck(byte[] buf,
int offset,
int length)
Verifies that length doesn't exceed a buffer's length
|
protected int |
size() |
long |
skip(long n) |
String |
toString() |
void |
write(byte[] buf)
Appends bytes to the end of the stream
|
void |
write(byte[] buf,
int offset,
int length)
Appends bytes to the end of the stream.
|
mark, markSupported, resetprotected boolean closed
close() is calledprotected final byte[] buf
protected int read_pos
protected int write_pos
protected final Lock lock
protected final Condition not_full
protected final Condition not_empty
public BlockingInputStream()
public BlockingInputStream(int capacity)
public int read()
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b)
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionpublic void write(byte[] buf)
throws IOException
buf - IOExceptionwrite(byte[],int,int)public void write(byte[] buf,
int offset,
int length)
throws IOException
buf - The buffer to be added to the end of the streamoffset - The offset within buf at which bytes are readlength - The number of bytes to be addedIOExceptionpublic long skip(long n)
throws IOException
skip in class InputStreamIOExceptionpublic int available()
throws IOException
available in class InputStreamIOExceptionpublic int capacity()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionpublic boolean isClosed()
protected int size()
protected int remaining()
protected void compact()
protected static void sanityCheck(byte[] buf,
int offset,
int length)
buf - offset - length - Copyright © 2012 JBoss by Red Hat. All Rights Reserved.