Class DeltaInputStream

java.lang.Object
java.io.InputStream
org.tukaani.xz.DeltaInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class DeltaInputStream
extends InputStream
Decodes raw Delta-filtered data (no XZ headers).

The delta filter doesn't change the size of the data and thus it cannot have an end-of-payload marker. It will simply decode until its input stream indicates end of input.

  • Field Details

    • DISTANCE_MIN

      public static final int DISTANCE_MIN
      Smallest supported delta calculation distance.
      See Also:
      Constant Field Values
    • DISTANCE_MAX

      public static final int DISTANCE_MAX
      Largest supported delta calculation distance.
      See Also:
      Constant Field Values
  • Constructor Details

    • DeltaInputStream

      public DeltaInputStream​(InputStream in, int distance)
      Creates a new Delta decoder with the given delta calculation distance.
      Parameters:
      in - input stream from which Delta filtered data is read
      distance - delta calculation distance, must be in the range [DISTANCE_MIN, DISTANCE_MAX]
  • Method Details

    • read

      public int read() throws IOException
      Decode the next byte from this input stream.
      Specified by:
      read in class InputStream
      Returns:
      the next decoded byte, or -1 to indicate the end of input on the input stream in
      Throws:
      IOException - may be thrown by in
    • read

      public int read​(byte[] buf, int off, int len) throws IOException
      Decode into an array of bytes.

      This calls in.read(buf, off, len) and defilters the returned data.

      Overrides:
      read in class InputStream
      Parameters:
      buf - target buffer for decoded data
      off - start offset in buf
      len - maximum number of bytes to read
      Returns:
      number of bytes read, or -1 to indicate the end of the input stream in
      Throws:
      XZIOException - if the stream has been closed
      IOException - may be thrown by underlaying input stream in
    • available

      public int available() throws IOException
      Calls in.available().
      Overrides:
      available in class InputStream
      Returns:
      the value returned by in.available()
      Throws:
      IOException
    • close

      public void close() throws IOException
      Closes the stream and calls in.close(). If the stream was already closed, this does nothing.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
      Throws:
      IOException - if thrown by in.close()