com.ibm.as400.access
Class SpooledFileOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.ibm.as400.access.SpooledFileOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class SpooledFileOutputStream
extends OutputStream

The SpooledFileOutputStream class is used to write data into a spooled file.


Constructor Summary
Constructor and Description
SpooledFileOutputStream(AS400 system, PrintParameterList options, PrinterFile printerFile, OutputQueue outputQueue)
          Constructs a SpooledFileOutputStream object.
 
Method Summary
Modifier and Type Method and Description
 void close()
          Closes the stream.
 void flush()
          Flushes the stream.
 SpooledFile getSpooledFile()
          Returns the spooled file that was created (or is being created) with this output stream.
 void write(byte[] data)
          Writes data.length bytes of data from the byte array data to the spooled file.
 void write(byte[] data, int offset, int length)
          Writes up to length bytes of data from the byte array data, starting at offset, to this spooled file.
 void write(int b)
          Writes a byte of data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpooledFileOutputStream

public SpooledFileOutputStream(AS400 system,
                               PrintParameterList options,
                               PrinterFile printerFile,
                               OutputQueue outputQueue)
                        throws AS400Exception,
                               AS400SecurityException,
                               ErrorCompletingRequestException,
                               InterruptedException,
                               IOException
Constructs a SpooledFileOutputStream object. Use this object to create a new spooled file on the given system with the specified parameters.

Parameters:
system - The system on which to create the spooled file.
options - Optional. A print parameter list that contains a list of attributes with which to create the spooled file. The attributes set in options will override those attributes in the printer file that is used. The printer file used will be the one specified with the printerFile parameter, or if that parameter is null, it will be the default network print server printer file (QPNPSPRTF). If the output queue is specified in options, it will override any output queue passed in the outputQueue parameter. The following parameters may be set: Note 1: Code page and graphical character set are dependent upon each other. If you set one you must set the other.
Note 2: The special value of *FILE is not allowed when creating a new spooled file.
Note 3: Up to 4 user-defined options may be specified.
Note 4: A page definition can be specified with *LINE data.

printerFile - Optional. The printer file that should be used to create the spooled file. This printer file must reside on the same system that the spooled file is being created on.
outputQueue - Optional. The output queue on which to create the spooled file. The output queue must reside on the same system that the spooled file is being created on.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
IOException - If an error occurs while communicating with the system.
InterruptedException - If this thread is interrupted.
Method Detail

close

public void close()
           throws IOException
Closes the stream. It must be called to release any resources associated with the stream.

Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException - If an error occurs while communicating with the system.

flush

public void flush()
           throws IOException
Flushes the stream. This will write any buffered output bytes.

Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException - If an error occurs while communicating with the system.

getSpooledFile

public SpooledFile getSpooledFile()
                           throws IOException
Returns the spooled file that was created (or is being created) with this output stream.

Returns:
A reference to the spooled file object.
Throws:
IOException

write

public void write(int b)
           throws IOException
Writes a byte of data.

Specified by:
write in class OutputStream
Parameters:
b - The byte to be written.
Throws:
IOException - If an error occurs while communicating with the system.

write

public void write(byte[] data)
           throws IOException
Writes data.length bytes of data from the byte array data to the spooled file.

Overrides:
write in class OutputStream
Parameters:
data - The data to be written.
Throws:
IOException - If an error occurs while communicating with the system.

write

public void write(byte[] data,
                  int offset,
                  int length)
           throws IOException
Writes up to length bytes of data from the byte array data, starting at offset, to this spooled file.

Overrides:
write in class OutputStream
Parameters:
data - The data to be written.
offset - The start offset in the data.
length - The number of bytes that are written.
Throws:
IOException - If an error occurs while communicating with the system.