com.ibm.as400.access

Class PrintObjectInputStream

  • java.lang.Object
    • java.io.InputStream
      • com.ibm.as400.access.PrintObjectInputStream
  • All Implemented Interfaces:
    java.io.Closeable


    public class PrintObjectInputStream
    extends java.io.InputStream
    Reads data out of a system spooled file or AFP resource such as an overlay or page segment.

    An instance of this class can be created either by using the getInputStream method from the AFPResource class or by using the getInputStream method from the SpooledFile class.

    • Method Summary

      Methods 
      Modifier and Type Method and Description
      int available()
      Returns the number of bytes that can be read without blocking.
      void close()
      Closes the input stream.
      void mark(int readLimit)
      Marks the current position in the input stream.
      boolean markSupported()
      Returns a boolean indicating whether this stream type supports mark/reset.
      int read()
      Reads the next byte of data from this input stream.
      int read(byte[] data)
      Reads up to data.length bytes of data from this input stream into data.
      int read(byte[] data, int dataOffset, int length)
      Reads up to length bytes of data from this input stream into data, starting at the array offset dataOffset.
      void reset()
      Repositions the stream to the last marked position.
      long skip(long bytesToSkip)
      Skips over the next bytesToSkip bytes in the stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • available

        public int available()
                      throws java.io.IOException
        Returns the number of bytes that can be read without blocking. This class always returns the number of bytes remaining in the spooled file or AFP resource.
        Overrides:
        available in class java.io.InputStream
        Returns:
        The number of available bytes without blocking.
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Closes the input stream. It must be called to release any resources associated with the stream.
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • mark

        public void mark(int readLimit)
        Marks the current position in the input stream. A subsequent call to reset() will reposition the stream at the last marked position, so that subsequent reads will reread the same bytes. The stream promises to allow readLimit bytes to be read before the mark position gets invalidated.
        Overrides:
        mark in class java.io.InputStream
        Parameters:
        readLimit - The maximum limit of bytes allowed to be read before the mark position becomes invalid.
      • markSupported

        public boolean markSupported()
        Returns a boolean indicating whether this stream type supports mark/reset.
        Overrides:
        markSupported in class java.io.InputStream
        Returns:
        Always true. Objects of this class will support the mark/reset methods.
      • read

        public int read()
                 throws java.io.IOException
        Reads the next byte of data from this input stream.
        Specified by:
        read in class java.io.InputStream
        Returns:
        The byte read, or -1 if the end of the stream is reached.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • read

        public int read(byte[] data)
                 throws java.io.IOException
        Reads up to data.length bytes of data from this input stream into data.
        Overrides:
        read in class java.io.InputStream
        Parameters:
        data - The buffer into which the data is read.
        Returns:
        The total number of bytes read into the buffer, or -1 if there is no more data because the end of file has been reached.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • read

        public int read(byte[] data,
               int dataOffset,
               int length)
                 throws java.io.IOException
        Reads up to length bytes of data from this input stream into data, starting at the array offset dataOffset.
        Overrides:
        read in class java.io.InputStream
        Parameters:
        data - The buffer into which the data is read.
        dataOffset - The start offset of the data.
        length - The maximum number of bytes to read.
        Returns:
        The total number of bytes read into the buffer, or -1 if there is no more data because the end of file has been reached.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • reset

        public void reset()
                   throws java.io.IOException
        Repositions the stream to the last marked position. If the stream has not been marked or if the mark has been invalidated, an IOException is thrown.
        Overrides:
        reset in class java.io.InputStream
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.
      • skip

        public long skip(long bytesToSkip)
                  throws java.io.IOException
        Skips over the next bytesToSkip bytes in the stream. This method may skip less bytes than specified if the end of file is reached. The actual number of bytes skipped is returned.
        Overrides:
        skip in class java.io.InputStream
        Parameters:
        bytesToSkip - The number of bytes to be skipped.
        Returns:
        The actual number of bytes skipped.
        Throws:
        java.io.IOException - If an error occurs while communicating with the system.