edu.rit.pj.cluster
Class BackendFileInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by edu.rit.pj.cluster.BackendFileInputStream
All Implemented Interfaces:
Closeable

public class BackendFileInputStream
extends InputStream

Class BackendFileInputStream provides an object in a job backend process that reads a sequential file in the job frontend process. A backend file input stream is not constructed directly, rather it is created by a factory method in class BackendFileReader.

Note: Class BackendFileInputStream does not do any buffering. Each method call sends a message to and receives a message from the job frontend. Consider layering a BufferedInputStream on top of the BackendFileInputStream.


Method Summary
 void close()
          Close this input stream.
 int read()
          Read a byte from this input stream.
 int read(byte[] buf)
          Read the given byte array from this input stream.
 int read(byte[] buf, int off, int len)
          Read a portion of the given byte array from this input stream.
 long skip(long len)
          Skip the given number of bytes from this input stream.
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

read

public int read()
         throws IOException
Read a byte from this input stream. The byte is returned as an int in the range 0 .. 255.

Specified by:
read in class InputStream
Returns:
Byte, or -1 if the end-of-stream was encountered.
Throws:
IOException - Thrown if an I/O error occurred.

read

public int read(byte[] buf)
         throws IOException
Read the given byte array from this input stream.

Overrides:
read in class InputStream
Parameters:
buf - Byte array.
Returns:
Number of bytes actually read, or -1 if the end-of-stream was encountered.
Throws:
NullPointerException - (unchecked exception) Thrown if buf is null.
IOException - Thrown if an I/O error occurred.

read

public int read(byte[] buf,
                int off,
                int len)
         throws IOException
Read a portion of the given byte array from this input stream.

Overrides:
read in class InputStream
Parameters:
buf - Byte array.
off - Index of first byte to read.
len - Number of bytes to read.
Returns:
Number of bytes actually read, or -1 if the end-of-stream was encountered.
Throws:
NullPointerException - (unchecked exception) Thrown if buf is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if off < 0, len < 0, or off+len > buf.length.
IOException - Thrown if an I/O error occurred.

skip

public long skip(long len)
          throws IOException
Skip the given number of bytes from this input stream.

Overrides:
skip in class InputStream
Parameters:
len - Number of bytes to skip.
Returns:
Number of bytes actually skipped.
Throws:
IOException - Thrown if an I/O error occurred.

close

public void close()
           throws IOException
Close this input stream.

Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException - Thrown if an I/O error occurred.


Copyright © 2005-2012 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.