Code example for InflaterInputStream

0
  protected void ensureInflated() { 
    if (compressed != null) {
      try { 
        ByteArrayInputStream deflated = new ByteArrayInputStream(compressed);
        DataInput inflater =
          new DataInputStream(new InflaterInputStream(deflated));
        readFieldsCompressed(inflater);
        compressed = null;
      } catch (IOException e) {
        throw new RuntimeException(e);
      } 
    } 
  } 
 
  /** Subclasses implement this instead of {@link #readFields(DataInput)}. */ 
  protected abstract void readFieldsCompressed(DataInput in)
    throws IOException; 
 
  public final void write(DataOutput out) throws IOException {
    if (compressed == null) {
      ByteArrayOutputStream deflated = new ByteArrayOutputStream();