| Method from com.sshtools.j2ssh.io.DynamicBuffer Detail: |
protected synchronized int available() {
return writepos - readpos;
}
Return the number of bytes of data available to be read from the buffer |
public synchronized void close() {
if (!closed) {
closed = true;
notifyAll();
}
}
|
protected synchronized void flush() throws IOException {
notifyAll();
}
|
public InputStream getInputStream() {
return in;
}
Get the InputStream of this buffer. Use the stream to read data from
this buffer. |
public OutputStream getOutputStream() {
return out;
}
Get the OutputStream of the buffer. Use this stream to write data to
the buffer. |
protected synchronized int read() throws IOException {
try {
block();
} catch (InterruptedException ex) {
throw new InterruptedIOException(
"The blocking operation was interrupted");
}
if (closed && (available() < = 0)) {
return -1;
}
return (int) buf[readpos++];
}
Read a byte from the buffer |
protected synchronized int read(byte[] data,
int offset,
int len) throws IOException {
try {
block();
} catch (InterruptedException ex) {
throw new InterruptedIOException(
"The blocking operation was interrupted");
}
if (closed && (available() < = 0)) {
return -1;
}
int read = (len > (writepos - readpos)) ? (writepos - readpos) : len;
System.arraycopy(buf, readpos, data, offset, read);
readpos += read;
return read;
}
Read a byte array from the buffer |
public void setBlockInterrupt(int interrupt) {
this.interrupt = interrupt;
}
|
protected synchronized void write(int b) throws IOException {
if (closed) {
throw new IOException("The buffer is closed");
}
verifyBufferSize(1);
buf[writepos] = (byte) b;
writepos++;
notifyAll();
}
Write a byte array to the buffer |
protected synchronized void write(byte[] data,
int offset,
int len) throws IOException {
if (closed) {
throw new IOException("The buffer is closed");
}
verifyBufferSize(len);
System.arraycopy(data, offset, buf, writepos, len);
writepos += len;
notifyAll();
}
|