Class PartialOutputStream

  • All Implemented Interfaces:
    java.io.DataOutput

    public class PartialOutputStream
    extends BaseDataOutputStream
    Decorates an output stream (DataOutput) and writes only a subset [start..end] (both indices inclusive) of the original data to the underlying output stream.
    Example:
    start=5, length=5: range=[5..9], bytes are written for positions 5,6,7,8,9 (5 bytes)
    Since:
    5.0
    Author:
    Bela Ban
    • Field Detail

      • out

        protected final java.io.DataOutput out
      • offset

        protected final int offset
      • end

        protected final int end
    • Constructor Detail

      • PartialOutputStream

        public PartialOutputStream​(java.io.DataOutput out,
                                   int offset,
                                   int length)
    • Method Detail

      • write

        public void write​(int b)
        Specified by:
        write in interface java.io.DataOutput
        Specified by:
        write in class BaseDataOutputStream
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
        Specified by:
        write in interface java.io.DataOutput
        Specified by:
        write in class BaseDataOutputStream
      • remaining

        public int remaining()
        Number of bytes left to be written
      • ensureCapacity

        protected void ensureCapacity​(int bytes)
        Description copied from class: BaseDataOutputStream
        Makes sure that bytes can be written to the output stream (e.g. a byte array has enough space left)
        Specified by:
        ensureCapacity in class BaseDataOutputStream
      • _write

        protected void _write​(int b)
      • _write

        protected void _write​(byte[] b,
                              int off,
                              int len)
      • inRange

        protected boolean inRange()
        Checks if pos is in range [offset..end]