Class StreamFile
- java.lang.Object
-
- edu.rit.pj.io.StreamFile
-
public class StreamFile extends java.lang.ObjectClass 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
Constructors Constructor and Description StreamFile(java.io.File theFile)Construct a new stream file that refers to the given file in the frontend processor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanequals(java.lang.Object obj)Determine if this stream file is equal to the given object.java.io.FilegetFile()Obtain the file in the frontend processor to which this stream file refers.java.io.InputStreamgetInputStream()Open an input stream for reading this stream file.java.io.OutputStreamgetOutputStream()Open an output stream for writing this stream file.java.io.OutputStreamgetOutputStream(boolean append)Open an output stream for writing this stream file.inthashCode()Returns a hash code for this stream file.java.lang.StringtoString()Returns a string version of this stream file.
-
-
-
Constructor Detail
-
StreamFile
public StreamFile(java.io.File theFile)
Construct a new stream file that refers to the given file in the frontend processor.- Parameters:
theFile- File.- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if theFile is null.
-
-
Method Detail
-
getFile
public java.io.File getFile()
Obtain the file in the frontend processor to which this stream file refers.- Returns:
- File.
-
getOutputStream
public java.io.OutputStream getOutputStream() throws java.io.IOExceptionOpen 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:
java.io.IOException- Thrown if an I/O error occurred.
-
getOutputStream
public java.io.OutputStream getOutputStream(boolean append) throws java.io.IOExceptionOpen 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:
java.io.IOException- Thrown if an I/O error occurred.
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOExceptionOpen 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:
java.io.IOException- Thrown if an I/O error occurred.
-
equals
public boolean equals(java.lang.Object obj)
Determine if this stream file is equal to the given object.- Overrides:
equalsin classjava.lang.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:
hashCodein classjava.lang.Object- Returns:
- Hash code.
-
toString
public java.lang.String toString()
Returns a string version of this stream file.- Overrides:
toStringin classjava.lang.Object- Returns:
- String version.
-
-
DMelt 3.0 © DataMelt by jWork.ORG