edu.rit.pj.io
Class StreamFile

java.lang.Object
  extended by 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.


Constructor Summary
StreamFile(File theFile)
          Construct a new stream file that refers to the given file in the frontend processor.
 
Method Summary
 boolean equals(Object obj)
          Determine if this stream file is equal to the given object.
 File getFile()
          Obtain the file in the frontend processor to which this stream file refers.
 InputStream getInputStream()
          Open an input stream for reading this stream file.
 OutputStream getOutputStream()
          Open an output stream for writing this stream file.
 OutputStream getOutputStream(boolean append)
          Open an output stream for writing this stream file.
 int hashCode()
          Returns a hash code for this stream file.
 String toString()
          Returns a string version of this stream file.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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 Detail

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.

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.

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.

equals

public boolean equals(Object obj)
Determine if this stream file is equal to the given object.

Overrides:
equals in class Object
Parameters:
obj - Object to test.
Returns:
True if this stream file is equal to obj, false otherwise.

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.


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