ByteArrayOutputStream bos = new ByteArrayOutputStream(idx); GZIPOutputStream gzos = new GZIPOutputStream(bos, idx); gzos.write(w, 0, idx);
ByteBufferOutputStream bos = new ByteBufferOutputStream( workBytes.length); GZIPOutputStream gzos = new GZIPOutputStream(bos, workBytes.length); gzos.write(workBytes);
    private void record200(String url, InputStream in, long lastModified,            HttpServletRequest request, HttpServletResponse response)            throws IOException, ServletException {        int ex = url.lastIndexOf('.');        int ex2 = url.lastIndexOf('/');        if (ex < 0 || ex < ex2) {            throw new ServletException("Can not find extension of url '" + url                    + "'");        }        String extension = url.substring(ex + 1).toLowerCase();        String mimeType = (String) extensions.get(extension);        if (mimeType == null) {            throw new ServletException("Unknown extension '" + extension + "'");        }        int idx = 0;        for (; idx < workBytes.length;) {            int ret = in.read(workBytes, idx, workBytes.length - idx);            if (ret <= 0) {                break;            }            idx += ret;        }        if (idx >= workBytes.length) {            throw new ServletException("Alert content of url '" + url                    + "' is too big. (max='" + workBytes.length + "' bytes)");        }        byte w[] = workBytes;        if (useFilterExtensions.contains(extension)) {            String filtered = SourceFilter.filter(new String(workBytes, 0, idx,                    getCharset()));            w = filtered.getBytes(getCharset());            idx = w.length;        } else if (useFilterSkipSpacesExtensions.contains(extension)) {            String filtered = SourceFilter.filterSkipSpaces(new String(                    workBytes, 0, idx, getCharset()));            w = filtered.getBytes(getCharset());            idx = w.length;        }        byte bufferGZIP[] = null;        if (hasGZipSupport()) {            if (useGZIPExtensions.contains(extension)) {                try {                    ByteArrayOutputStream bos = new ByteArrayOutputStream(idx);                    GZIPOutputStream gzos = new GZIPOutputStream(bos, idx);                    gzos.write(w, 0, idx);                    gzos.close();                    bufferGZIP = bos.toByteArray();                    bos.close();                } catch (IOException ex3) {                    throw new ServletException(                            "Can not create GZIP buffer of adonis css files.",                            ex3);                }            }        }        Response res = new BytesResponse(w, idx, mimeType, bufferGZIP,                lastModified);        synchronized (bufferedResponse) {            bufferedResponse.put(url, res);        }        count200Responses++;        if (response != null) {            res.send(request, response);        }    }