Class PaddedInputByteStream

  • All Implemented Interfaces:
    InputByteStream

    public class PaddedInputByteStream
    extends InputByteStreamImpl
    Only for internal engineering use. This api can change without notice. This class provides access to a seekable input stream with support of padding without allocating any extra memory. This class's object wraps inside it an InputByteStream. It extends the InputByteStreamImpl abstract class.
    • Constructor Detail

      • PaddedInputByteStream

        public PaddedInputByteStream​(InputByteStream ibs,
                                     int paddedChar,
                                     long padLength)
        constructor with InputByteStream, character to be padded and padding length as parameters.
        Parameters:
        ibs -
        paddedChar -
        padLength -
    • Method Detail

      • close

        public void close()
                   throws IOException
        Closes this InputByteStream and releases any system resources associated with the stream. After this method is called then any further calls to this instance are errors.
        Specified by:
        close in interface InputByteStream
        Specified by:
        close in class InputByteStreamImpl
        Throws:
        IOException
      • read

        public int read()
                 throws IOException
        Read the byte at the current position. If the current position is at or beyond the end of the underlying data return a -1. If not beyond the end of the underlying data the current position is incremented by 1.
        Specified by:
        read in interface InputByteStream
        Specified by:
        read in class InputByteStreamImpl
        Returns:
        The byte at the current position or -1 if at or beyond EOF.
        Throws:
        IOException
      • read

        public int read​(byte[] bytes,
                        int position,
                        int length)
                 throws IOException
        Read an array of bytes starting at the current position. The position is incremented by the length of the array that has been read.
        Specified by:
        read in interface InputByteStream
        Specified by:
        read in class InputByteStreamImpl
        Parameters:
        bytes - The destination array.
        position - The offset in the byte array to put the first byte read.
        length - The number of bytes to read.
        Throws:
        IOException
      • seek

        public InputByteStream seek​(long position)
                             throws IOException
        Set the current position in the underlying data. This position is pegged to be no less than zero and no greater than the length of the InputByteStream.
        Specified by:
        seek in interface InputByteStream
        Specified by:
        seek in class InputByteStreamImpl
        Parameters:
        position - Where to set the current position.
        Returns:
        This object.
        Throws:
        IOException
      • slice

        public InputByteStream slice​(long begin,
                                     long length)
                              throws IOException
        Create a new InputByteStream that provides another view on the underlying data. This new InputByteStream is completely independent and can be read from and positioned without affecting the original or any other slice InputByteStream objects. The initial position of the slice is at zero - the beginning of the slice.
        Specified by:
        slice in interface InputByteStream
        Specified by:
        slice in class InputByteStreamImpl
        Parameters:
        begin - Offset within the current InputByteStream to start the slice.
        length - The length of the slice.
        Returns:
        A slice of the original InputByteStream.
        Throws:
        IOException