import java.io.*; import java.util.zip.*; public class CompressedInputStream extends FilterInputStream { Inflater inflater; // The inflater protected byte buf[]; // The internal buffer where uncompressed data is stored protected int pos; // The current position in the buffer. protected int count; // The index one greater than the index of the last valid byte in the buffer. private void ensureOpen() throws IOException { if (in == null) throw new IOException("Stream closed"); } public CompressedInputStream(InputStream in) { super(in); inflater = new Inflater(); } private void fill() throws IOException { InflaterInputStream iis = new InflaterInputStream(in); DataInputStream dataIn = new DataInputStream(iis); int noBytes = 0; try { noBytes = dataIn.readInt(); buf = new byte[noBytes]; } catch (EOFException ee) { return; } System.err.println("reading="+noBytes); count = dataIn.read(buf,0,noBytes); pos = 0; } public synchronized int read() throws IOException { ensureOpen(); if (pos >= count) { fill(); if (pos >= count) return -1; } return buf[pos++] & 0xff; } public synchronized int read(byte b[], int off, int len) throws IOException { ensureOpen(); for (int i=0; i