public class BlockingInputStream
extends java.io.InputStream
Modifier and Type | Field and Description |
---|---|
protected byte[] |
buf
The transfer buffer
|
protected boolean |
closed
Set to true when
close() is called |
protected java.util.concurrent.locks.Lock |
lock |
protected java.util.concurrent.locks.Condition |
not_empty
Signalled when the buf becomes 'readable'; ie.
|
protected java.util.concurrent.locks.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) |
java.lang.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.
|
protected boolean closed
close()
is calledprotected final byte[] buf
protected int read_pos
protected int write_pos
protected final java.util.concurrent.locks.Lock lock
protected final java.util.concurrent.locks.Condition not_full
protected final java.util.concurrent.locks.Condition not_empty
public BlockingInputStream()
public BlockingInputStream(int capacity)
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] b) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public void write(byte[] buf) throws java.io.IOException
buf
- java.io.IOException
write(byte[],int,int)
public void write(byte[] buf, int offset, int length) throws java.io.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 addedjava.io.IOException
public long skip(long n) throws java.io.IOException
skip
in class java.io.InputStream
java.io.IOException
public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException
public int capacity()
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException
public boolean isClosed()
public java.lang.String toString()
toString
in class java.lang.Object
protected int size()
protected int remaining()
protected void compact()
protected static void sanityCheck(byte[] buf, int offset, int length)
buf
- offset
- length
- Copyright © 1998-2020 Red Hat. All Rights Reserved.