org.jppf.utils.streams
Class MultipleBuffersOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.jppf.utils.streams.MultipleBuffersOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class MultipleBuffersOutputStream
extends OutputStream

An output stream implementation that minimizes memory usage.

Author:
Laurent Cohen

Constructor Summary
MultipleBuffersOutputStream()
          Intialize this output stream with a default buffer length of 32768.
MultipleBuffersOutputStream(int defaultLength)
          Intialize this output stream with the specified default buffer length.
MultipleBuffersOutputStream(List<JPPFBuffer> initialList)
          Intialize this output stream with a default buffer length of 32768.
 
Method Summary
 int size()
          Get the size of the content of this output stream.
 List<JPPFBuffer> toBufferList()
          Get the content of the output stream as a list of JPPFBuffer instances.
 byte[] toByteArray()
          Get te content of the output stream as a single array of byte
 String toString()
          
 void write(byte[] b)
          Writes the specified byte array to this output stream.
 void write(byte[] b, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to this output stream.
 void write(int b)
          Write a single byte into this output stream.
 
Methods inherited from class java.io.OutputStream
close, flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MultipleBuffersOutputStream

public MultipleBuffersOutputStream()
Intialize this output stream with a default buffer length of 32768.


MultipleBuffersOutputStream

public MultipleBuffersOutputStream(List<JPPFBuffer> initialList)
Intialize this output stream with a default buffer length of 32768.

Parameters:
initialList - contains the data that is written to this output stream.

MultipleBuffersOutputStream

public MultipleBuffersOutputStream(int defaultLength)
                            throws IllegalArgumentException
Intialize this output stream with the specified default buffer length.

Parameters:
defaultLength - the default buffer length to use, must be strictly greater than 0.
Throws:
IllegalArgumentException - if the specified default length is less than 1.
Method Detail

write

public void write(int b)
           throws IOException
Write a single byte into this output stream.

Specified by:
write in class OutputStream
Parameters:
b - the data to write.
Throws:
IOException - if any error occurs.
See Also:
OutputStream.write(int)

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Writes len bytes from the specified byte array starting at offset off to this output stream.

Overrides:
write in class OutputStream
Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws:
IOException - if any error occurs.
See Also:
OutputStream.write(byte[], int, int)

write

public void write(byte[] b)
           throws IOException
Writes the specified byte array to this output stream.

Overrides:
write in class OutputStream
Parameters:
b - the data to write.
Throws:
IOException - if any error occurs.
See Also:
OutputStream.write(byte[])

size

public int size()
Get the size of the content of this output stream.

Returns:
the size as an int value.

toBufferList

public List<JPPFBuffer> toBufferList()
Get the content of the output stream as a list of JPPFBuffer instances.

Returns:
a list of JPPFBuffer instances.

toByteArray

public byte[] toByteArray()
Get te content of the output stream as a single array of byte

Returns:
an array of bytes.

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2005-2010 JPPF Team.