com.ibm.as400.access
Class SpooledFileOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--com.ibm.as400.access.SpooledFileOutputStream

public class SpooledFileOutputStream
extends java.io.OutputStream

The SpooledFileOutputStream class is used to write data into an AS/400 spooled file.


Constructor Summary
SpooledFileOutputStream(AS400 system, PrintParameterList options, PrinterFile printerFile, OutputQueue outputQueue)
          Constructs a SpooledFileOutputStream object.
 
Method Summary
 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,
                               java.lang.InterruptedException,
                               java.io.IOException
Constructs a SpooledFileOutputStream object. Use this object to create a new spooled file on the given AS/400 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 AS400 system that the spooled file is being created.
outputQueue - Optional. The output queue on which to create the spooled file. The output queue must reside on the same AS400 system that the spooled file is being created.
Throws:
AS400Exception - If the AS/400 system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
java.io.IOException - If an error occurs while communicating with the AS/400.
java.lang.InterruptedException - If this thread is interrupted.
Method Detail

close

public void close()
           throws java.io.IOException
Closes the stream. It must be called to release any resources associated with the stream.
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException - If an error occurs while communicating with the AS/400.

flush

public void flush()
           throws java.io.IOException
Flushes the stream. This will write any buffered output bytes.
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException - If an error occurs while communicating with the AS/400.

getSpooledFile

public SpooledFile getSpooledFile()
                           throws java.io.IOException
Returns the spooled file that was created (or is being created) with this output stream.
Returns:
A reference to the spooled file object.

write

public void write(int b)
           throws java.io.IOException
Writes a byte of data.
Overrides:
write in class java.io.OutputStream
Parameters:
b - The byte to be written.
Throws:
java.io.IOException - If an error occurs while communicating with the AS/400.

write

public void write(byte[] data)
           throws java.io.IOException
Writes data.length bytes of data from the byte array data to the spooled file.
Overrides:
write in class java.io.OutputStream
Parameters:
data - The data to be written.
Throws:
java.io.IOException - If an error occurs while communicating with the AS/400.

write

public void write(byte[] data,
                  int offset,
                  int length)
           throws java.io.IOException
Writes up to length bytes of data from the byte array data, starting at offset, to this spooled file.
Overrides:
write in class java.io.OutputStream
Parameters:
data - The data to be written.
offset - The start offset in the data.
length - The number of bytes that are written.
Throws:
java.io.IOException - If an error occurs while communicating with the AS/400.