< prev index next >

src/java.base/share/classes/java/util/zip/Inflater.java

Print this page




  51  *     int compressedDataLength = compresser.deflate(output);
  52  *
  53  *     // Decompress the bytes
  54  *     Inflater decompresser = new Inflater();
  55  *     decompresser.setInput(output, 0, compressedDataLength);
  56  *     byte[] result = new byte[100];
  57  *     int resultLength = decompresser.inflate(result);
  58  *     decompresser.end();
  59  *
  60  *     // Decode the bytes into a String
  61  *     String outputString = new String(result, 0, resultLength, "UTF-8");
  62  * } catch(java.io.UnsupportedEncodingException ex) {
  63  *     // handle
  64  * } catch (java.util.zip.DataFormatException ex) {
  65  *     // handle
  66  * }
  67  * </pre></blockquote>
  68  *
  69  * @see         Deflater
  70  * @author      David Connelly

  71  *
  72  */
  73 public
  74 class Inflater {
  75 
  76     private final ZStreamRef zsRef;
  77     private byte[] buf = defaultBuf;
  78     private int off, len;
  79     private boolean finished;
  80     private boolean needDict;
  81     private long bytesRead;
  82     private long bytesWritten;
  83 
  84     private static final byte[] defaultBuf = new byte[0];
  85 
  86     static {
  87         /* Zip library is loaded from System.initializeSystemClass */
  88         initIDs();
  89     }
  90 




  51  *     int compressedDataLength = compresser.deflate(output);
  52  *
  53  *     // Decompress the bytes
  54  *     Inflater decompresser = new Inflater();
  55  *     decompresser.setInput(output, 0, compressedDataLength);
  56  *     byte[] result = new byte[100];
  57  *     int resultLength = decompresser.inflate(result);
  58  *     decompresser.end();
  59  *
  60  *     // Decode the bytes into a String
  61  *     String outputString = new String(result, 0, resultLength, "UTF-8");
  62  * } catch(java.io.UnsupportedEncodingException ex) {
  63  *     // handle
  64  * } catch (java.util.zip.DataFormatException ex) {
  65  *     // handle
  66  * }
  67  * </pre></blockquote>
  68  *
  69  * @see         Deflater
  70  * @author      David Connelly
  71  * @since 1.1
  72  *
  73  */
  74 public
  75 class Inflater {
  76 
  77     private final ZStreamRef zsRef;
  78     private byte[] buf = defaultBuf;
  79     private int off, len;
  80     private boolean finished;
  81     private boolean needDict;
  82     private long bytesRead;
  83     private long bytesWritten;
  84 
  85     private static final byte[] defaultBuf = new byte[0];
  86 
  87     static {
  88         /* Zip library is loaded from System.initializeSystemClass */
  89         initIDs();
  90     }
  91 


< prev index next >