private int inflate(byte[] src, byte[] dest) {

        // construct the inflater object or reuse an existing one
        if (inflater == null)
            inflater = new Inflater(true);

        synchronized (inflater) {
            inflater.reset();
            inflater.setInput(src);
            try {
                return inflater.inflate(dest);
            } catch (DataFormatException ex) {
                return -1;
            }
        }
    }