org.jppf.utils.streams
Class MultipleBuffersInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.jppf.utils.streams.MultipleBuffersInputStream
All Implemented Interfaces:
Closeable

public class MultipleBuffersInputStream
extends InputStream

An output stream implementation that minimizes memory usage.

Author:
Laurent Cohen

Constructor Summary
MultipleBuffersInputStream(JPPFBuffer... buffers)
          Intialize this input stream with the specified buffers.
MultipleBuffersInputStream(List<JPPFBuffer> buffers)
          Intialize this input stream with the specified buffers.
 
Method Summary
 JPPFBuffer getCurrentBuffer()
          Get the JPPFBuffer currently being read from.
 int read()
          Read a single byte from this input stream.
 int read(byte[] b)
          Writes the specified byte array to this output stream.
 int read(byte[] b, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to this output stream.
 String toString()
          
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MultipleBuffersInputStream

public MultipleBuffersInputStream(JPPFBuffer... buffers)
Intialize this input stream with the specified buffers.

Parameters:
buffers - an array of JPPFBuffer instances.

MultipleBuffersInputStream

public MultipleBuffersInputStream(List<JPPFBuffer> buffers)
Intialize this input stream with the specified buffers.

Parameters:
buffers - an array of JPPFBuffer instances.
Method Detail

read

public int read()
         throws IOException
Read a single byte from this input stream.

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

read

public int read(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:
read in class InputStream
Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Returns:
the number of bytes read from the stream, or -1 if end of file was reached.
Throws:
IOException - if any error occurs.
See Also:
OutputStream.write(byte[], int, int)

read

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

Overrides:
read in class InputStream
Parameters:
b - the data to write.
Returns:
the number of bytes read from the stream, or -1 if end of file was reached.
Throws:
IOException - if any error occurs.
See Also:
OutputStream.write(byte[])

getCurrentBuffer

public JPPFBuffer getCurrentBuffer()
Get the JPPFBuffer currently being read from.

Returns:
a JPPFBuffer instance.

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2005-2010 JPPF Team.