Package okio

Class InflaterSource

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, Source

    public final class InflaterSource
    extends java.lang.Object
    implements Source
    A source that uses DEFLATE to decompress data read from another source.
    • Constructor Summary

      Constructors 
      Constructor Description
      InflaterSource​(Source source, java.util.zip.Inflater inflater)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes this source and releases the resources held by this source.
      long read​(Buffer sink, long byteCount)
      Removes at least 1, and up to byteCount bytes from this and appends them to sink.
      boolean refill()
      Refills the inflater with compressed data if it needs input.
      Timeout timeout()
      Returns the timeout for this source.
      • Methods inherited from class java.lang.Object

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

      • InflaterSource

        public InflaterSource​(Source source,
                              java.util.zip.Inflater inflater)
    • Method Detail

      • read

        public long read​(Buffer sink,
                         long byteCount)
                  throws java.io.IOException
        Description copied from interface: Source
        Removes at least 1, and up to byteCount bytes from this and appends them to sink. Returns the number of bytes read, or -1 if this source is exhausted.
        Specified by:
        read in interface Source
        Throws:
        java.io.IOException
      • refill

        public final boolean refill()
                             throws java.io.IOException
        Refills the inflater with compressed data if it needs input. (And only if it needs input). Returns true if the inflater required input but the source was exhausted.
        Throws:
        java.io.IOException
      • timeout

        public Timeout timeout()
        Description copied from interface: Source
        Returns the timeout for this source.
        Specified by:
        timeout in interface Source
      • close

        public void close()
                   throws java.io.IOException
        Description copied from interface: Source
        Closes this source and releases the resources held by this source. It is an error to read a closed source. It is safe to close a source more than once.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface Source
        Throws:
        java.io.IOException