org.jppf.io
Class StreamInputSource

java.lang.Object
  extended by org.jppf.io.StreamInputSource
All Implemented Interfaces:
Closeable, InputSource, IO

public class StreamInputSource
extends Object
implements InputSource

Input source that takes an input stream as its source.

Author:
Laurent Cohen

Constructor Summary
StreamInputSource(InputStream is)
          Initialize this stream input source with the specified input stream.
 
Method Summary
 void close()
          Close this input source and release any system resources associated with it.
 int read(byte[] data, int offset, int len)
          Read data from this input source into an array of bytes.
 int read(ByteBuffer buffer)
          Read data from this input source into a byte buffer.
 int readInt()
          Read an int value from this input source.
 int skip(int n)
          Skip n bytes of data form this input source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamInputSource

public StreamInputSource(InputStream is)
Initialize this stream input source with the specified input stream.

Parameters:
is - the input stream to read from.
Method Detail

read

public int read(byte[] data,
                int offset,
                int len)
         throws Exception
Read data from this input source into an array of bytes.

Specified by:
read in interface InputSource
Parameters:
data - the buffer into which to write.
offset - the position in the buffer where to start storing the data.
len - the size in bytes of the data to read.
Returns:
the number of bytes actually read, or -1 if end of stream was reached.
Throws:
Exception - if an IO error occurs.
See Also:
InputSource.read(byte[], int, int)

read

public int read(ByteBuffer buffer)
         throws Exception
Read data from this input source into a byte buffer.

Specified by:
read in interface InputSource
Parameters:
buffer - the buffer into which to write.
Returns:
the number of bytes actually read, or -1 if end of stream was reached.
Throws:
Exception - if an IO error occurs.
See Also:
InputSource.read(java.nio.ByteBuffer)

readInt

public int readInt()
            throws Exception
Read an int value from this input source.

Specified by:
readInt in interface InputSource
Returns:
the value read, or -1 if an end of file condition was reached.
Throws:
Exception - if an IO error occurs.
See Also:
InputSource.readInt()

skip

public int skip(int n)
         throws Exception
Skip n bytes of data form this input source.

Specified by:
skip in interface InputSource
Parameters:
n - the number of bytes to skip.
Returns:
the number of bytes actually skipped.
Throws:
Exception - if an IO error occurs.
See Also:
InputSource.skip(int)

close

public void close()
           throws IOException
Close this input source and release any system resources associated with it.

Specified by:
close in interface Closeable
Throws:
IOException - if an IO error occurs.
See Also:
Closeable.close()


Copyright © 2005-2010 JPPF Team.