Package edu.rit.pj.io

Class StreamFile

java.lang.Object
edu.rit.pj.io.StreamFile

public class StreamFile extends Object
Class StreamFile represents a file that resides in the user's account in the job frontend process of a PJ cluster parallel program. Operations are provided to open an input stream or an output stream to read or write the file in the frontend processor.
Version:
06-Nov-2006
Author:
Alan Kaminsky
  • Constructor Details

    • StreamFile

      public StreamFile(File theFile)
      Construct a new stream file that refers to the given file in the frontend processor.
      Parameters:
      theFile - File.
      Throws:
      NullPointerException - (unchecked exception) Thrown if theFile is null.
  • Method Details

    • getFile

      public File getFile()
      Obtain the file in the frontend processor to which this stream file refers.
      Returns:
      File.
    • getOutputStream

      public OutputStream getOutputStream() throws IOException
      Open an output stream for writing this stream file. If the file does not exist, it is created; if the file exists, it is overwritten.

      When called from a job backend process in a cluster parallel program, the returned output stream communicates with the job frontend process to write the file in the frontend processor. Otherwise, the returned output stream is a normal file output stream to write the file directly.

      Note: The returned output stream does not do any buffering. Each method call sends a message to and receives a message from the job frontend. Consider layering a BufferedOutputStream on top of the returned output stream.

      Returns:
      Output stream.
      Throws:
      IOException - Thrown if an I/O error occurred.
      IOException - if any.
    • getOutputStream

      public OutputStream getOutputStream(boolean append) throws IOException
      Open an output stream for writing this stream file. If the file does not exist, it is created; if the file exists and the append flag is false, the file is overwritten; if the file exists and the append flag is true, data is written after the end of the file.

      When called from a job backend process in a cluster parallel program, the returned output stream communicates with the job frontend process to write the file in the frontend processor. Otherwise, the returned output stream is a normal file output stream to write the file directly.

      Note: The returned output stream does not do any buffering. Each method call sends a message to and receives a message from the job frontend. Consider layering a BufferedOutputStream on top of the returned output stream.

      Parameters:
      append - True to append, false to overwrite.
      Returns:
      Output stream.
      Throws:
      IOException - Thrown if an I/O error occurred.
      IOException - if any.
    • getInputStream

      public InputStream getInputStream() throws IOException
      Open an input stream for reading this stream file.

      When called from a job backend process in a cluster parallel program, the returned input stream communicates with the job frontend process to read the file in the frontend processor. Otherwise, the returned input stream is a normal file input stream to read the file directly.

      Note: The returned input stream 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 returned input stream.

      Returns:
      Input stream.
      Throws:
      IOException - Thrown if an I/O error occurred.
      IOException - if any.
    • equals

      public boolean equals(Object obj)
      Determine if this stream file is equal to the given object.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns a hash code for this stream file.
      Overrides:
      hashCode in class Object
      Returns:
      Hash code.
    • toString

      public String toString()
      Returns a string version of this stream file.
      Overrides:
      toString in class Object
      Returns:
      String version.