Save This Page
Home » j2ssh-0.2.9-src » com.sshtools.j2ssh.io » [javadoc | source]
com.sshtools.j2ssh.io
public class: DynamicBuffer [javadoc | source]
java.lang.Object
   com.sshtools.j2ssh.io.DynamicBuffer

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.

*
Nested Class Summary:
class  DynamicBuffer.DynamicBufferInputStream   
class  DynamicBuffer.DynamicBufferOutputStream   
Field Summary
protected static final  int DEFAULT_BUFFER_SIZE    Buffer size when the dynamic buffer is opened 
protected  byte[] buf    The buffer 
protected  int writepos    The current write position 
protected  int readpos    The current read position 
protected  InputStream in    This buffers InputStream 
protected  OutputStream out    This buffers OutputStream 
Constructor:
 public DynamicBuffer() 
Method from com.sshtools.j2ssh.io.DynamicBuffer Summary:
available,   close,   flush,   getInputStream,   getOutputStream,   read,   read,   setBlockInterrupt,   write,   write
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.sshtools.j2ssh.io.DynamicBuffer Detail:
 protected synchronized int available() 
    Return the number of bytes of data available to be read from the buffer
 public synchronized  void close() 
    Closes the buffer
 protected synchronized  void flush() throws IOException 
    Flush data
 public InputStream getInputStream() 
    Get the InputStream of this buffer. Use the stream to read data from this buffer.
 public OutputStream getOutputStream() 
    Get the OutputStream of the buffer. Use this stream to write data to the buffer.
 protected synchronized int read() throws IOException 
    Read a byte from the buffer
 protected synchronized int read(byte[] data,
    int offset,
    int len) throws IOException 
    Read a byte array from the buffer
 public  void setBlockInterrupt(int interrupt) 
 protected synchronized  void write(int b) throws IOException 
    Write a byte array to the buffer
 protected synchronized  void write(byte[] data,
    int offset,
    int len) throws IOException