com.ibm.wbi.util
Class BytePipe

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--com.ibm.wbi.util.BytePipe

public class BytePipe
extends java.io.OutputStream

A BytePipe is used to "pipe" bytes from an OutputStream to an InputStream. The BytePipe uses a concept of byte buckets that hold written, which is then flushed to a byte repository for reading. This essentially breaks the stream down into logical byte "buckets" allowing buckets that have already been read to be discarded making the byte streaming process more memory efficient especially when a large quantity of bytes are streamed.


Constructor Summary
BytePipe()
          Construct a new BytePipe with a default byte bucket capacity.
BytePipe(int bufferCapacity)
          Construct a new BytePipe with the specified byte bucket capacity.
 
Method Summary
 void close()
          Flush and close the pipe stream making all bytes written available for a read.
 void flush()
          Flush the pipe stream making all bytes written available for a read.
 java.io.InputStream getInputStream()
          Get the InputStream to read byte from the Pipe.
 java.io.OutputStream getOutputStream()
          Get the OutputStream to write bytes to the Pipe.
 void write(byte[] b)
          Write an array of bytes to the pipe stream.
 void write(byte[] b, int off, int len)
          Write a portion of an array of bytes to the pipe stream.
 void write(int b)
          Write a single byte to the pipe stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BytePipe

public BytePipe()
Construct a new BytePipe with a default byte bucket capacity.

BytePipe

public BytePipe(int bufferCapacity)
Construct a new BytePipe with the specified byte bucket capacity.
Parameters:
bufferCapacity - The byte bucket capacity.
Method Detail

getInputStream

public java.io.InputStream getInputStream()
Get the InputStream to read byte from the Pipe.
Returns:
The BytePipe InputStream.

getOutputStream

public java.io.OutputStream getOutputStream()
Get the OutputStream to write bytes to the Pipe.
Parameters:
The - BytePipe OutputStream.

write

public void write(int b)
           throws java.io.IOException
Write a single byte to the pipe stream.
Overrides:
write in class java.io.OutputStream
Parameters:
b - The byte.
Throws:
java.io.IOException - If a write error occurs.

write

public void write(byte[] b)
           throws java.io.IOException
Write an array of bytes to the pipe stream.
Overrides:
write in class java.io.OutputStream
Parameters:
b - The array of bytes.
Throws:
java.io.IOException - If a write error occurs.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Write a portion of an array of bytes to the pipe stream.
Overrides:
write in class java.io.OutputStream
Parameters:
b - The array of bytes.
off - The offset into b to start from.
len - The length from off to write.
Throws:
java.io.IOException - If a write error occurs.

flush

public void flush()
           throws java.io.IOException
Flush the pipe stream making all bytes written available for a read.
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException - If a stream error occurs.

close

public void close()
           throws java.io.IOException
Flush and close the pipe stream making all bytes written available for a read.
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException - If a stream error occurs.