com.sshtools.j2ssh.io
Class DynamicBuffer
java.lang.Object
com.sshtools.j2ssh.io.DynamicBuffer
public class DynamicBuffer
extends java.lang.Object
This class provides an alternative method of storing data, used within the
API where Piped Streams could have been used. We found that Piped streams
would lock if a thread attempted to read to data when the OutputStream attached
was not being read; since we have no control over when the user will actually
read the data, this behaviour led us to develop this dynamic buffer which
will automatically grow if the buffer is full.
*
protected static int | DEFAULT_BUFFER_SIZE - Buffer size when the dynamic buffer is opened
|
protected byte[] | buf - The buffer
|
protected InputStream | in - This buffers InputStream
|
protected OutputStream | out - This buffers OutputStream
|
protected int | readpos - The current read position
|
protected int | writepos - The current write position
|
protected int | available() - Return the number of bytes of data available to be read from the buffer
|
void | close() - Closes the buffer
|
protected void | flush() - Flush data
|
InputStream | getInputStream() - Get the InputStream of this buffer.
|
OutputStream | getOutputStream() - Get the OutputStream of the buffer.
|
protected int | read() - Read a byte from the buffer
|
protected int | read(byte[] data, int offset, int len) - Read a byte array from the buffer
|
void | setBlockInterrupt(int interrupt)
|
protected void | write(byte[] data, int offset, int len)
|
protected void | write(int b) - Write a byte array to the buffer
|
DEFAULT_BUFFER_SIZE
protected static final int DEFAULT_BUFFER_SIZE
Buffer size when the dynamic buffer is opened
buf
protected byte[] buf
The buffer
in
protected InputStream in
This buffers InputStream
out
protected OutputStream out
This buffers OutputStream
readpos
protected int readpos
The current read position
writepos
protected int writepos
The current write position
DynamicBuffer
public DynamicBuffer()
Creates a new DynamicBuffer object.
available
protected int available()
Return the number of bytes of data available to be read from the buffer
close
public void close()
Closes the buffer
flush
protected void flush()
throws IOException
Flush data
getInputStream
public InputStream getInputStream()
Get the InputStream of this buffer. Use the stream to read data from
this buffer.
getOutputStream
public OutputStream getOutputStream()
Get the OutputStream of the buffer. Use this stream to write data to
the buffer.
read
protected int read()
throws IOException
Read a byte from the buffer
read
protected int read(byte[] data,
int offset,
int len)
throws IOException
Read a byte array from the buffer
setBlockInterrupt
public void setBlockInterrupt(int interrupt)
write
protected void write(byte[] data,
int offset,
int len)
throws IOException
write
protected void write(int b)
throws IOException
Write a byte array to the buffer
Copyright © 2002-2003 Lee David Painter & Contributors. All Rights Reserved.