亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? compressionresponsestream.java

?? 這是一個基于web的新聞發布系統!用jsp做的
?? JAVA
字號:
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package compressionFilters;

import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.GZIPOutputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;


/**
 * Implementation of <b>ServletOutputStream</b> that works with
 * the CompressionServletResponseWrapper implementation.
 *
 * @author Amy Roh
 * @author Dmitri Valdin
 * @version $Revision: 1.3 $, $Date: 2004/03/18 16:40:28 $
 */

public class CompressionResponseStream
    extends ServletOutputStream {


    // ----------------------------------------------------------- Constructors


    /**
     * Construct a servlet output stream associated with the specified Response.
     *
     * @param response The associated response
     */
    public CompressionResponseStream(HttpServletResponse response) throws IOException{

        super();
        closed = false;
        this.response = response;
        this.output = response.getOutputStream();

    }


    // ----------------------------------------------------- Instance Variables


    /**
     * The threshold number which decides to compress or not.
     * Users can configure in web.xml to set it to fit their needs.
     */
    protected int compressionThreshold = 0;

    /**
     * Debug level
     */
    private int debug = 0;

    /**
     * The buffer through which all of our output bytes are passed.
     */
    protected byte[] buffer = null;

    /**
     * The number of data bytes currently in the buffer.
     */
    protected int bufferCount = 0;

    /**
     * The underlying gzip output stream to which we should write data.
     */
    protected GZIPOutputStream gzipstream = null;

    /**
     * Has this stream been closed?
     */
    protected boolean closed = false;

    /**
     * The content length past which we will not write, or -1 if there is
     * no defined content length.
     */
    protected int length = -1;

    /**
     * The response with which this servlet output stream is associated.
     */
    protected HttpServletResponse response = null;

    /**
     * The underlying servket output stream to which we should write data.
     */
    protected ServletOutputStream output = null;


    // --------------------------------------------------------- Public Methods

    /**
     * Set debug level
     */
    public void setDebugLevel(int debug) {
        this.debug = debug;
    }


    /**
     * Set the compressionThreshold number and create buffer for this size
     */
    protected void setBuffer(int threshold) {
        compressionThreshold = threshold;
        buffer = new byte[compressionThreshold];
        if (debug > 1) {
            System.out.println("buffer is set to "+compressionThreshold);
        }
    }

    /**
     * Close this output stream, causing any buffered data to be flushed and
     * any further output data to throw an IOException.
     */
    public void close() throws IOException {

        if (debug > 1) {
            System.out.println("close() @ CompressionResponseStream");
        }
        if (closed)
            throw new IOException("This output stream has already been closed");

        if (gzipstream != null) {
            flushToGZip();
            gzipstream.close();
            gzipstream = null;
        } else {
            if (bufferCount > 0) {
                if (debug > 2) {
                    System.out.print("output.write(");
                    System.out.write(buffer, 0, bufferCount);
                    System.out.println(")");
                }
                output.write(buffer, 0, bufferCount);
                bufferCount = 0;
            }
        }

        output.close();
        closed = true;

    }


    /**
     * Flush any buffered data for this output stream, which also causes the
     * response to be committed.
     */
    public void flush() throws IOException {

        if (debug > 1) {
            System.out.println("flush() @ CompressionResponseStream");
        }
        if (closed) {
            throw new IOException("Cannot flush a closed output stream");
        }

        if (gzipstream != null) {
            gzipstream.flush();
        }

    }

    public void flushToGZip() throws IOException {

        if (debug > 1) {
            System.out.println("flushToGZip() @ CompressionResponseStream");
        }
        if (bufferCount > 0) {
            if (debug > 1) {
                System.out.println("flushing out to GZipStream, bufferCount = " + bufferCount);
            }
            writeToGZip(buffer, 0, bufferCount);
            bufferCount = 0;
        }

    }

    /**
     * Write the specified byte to our output stream.
     *
     * @param b The byte to be written
     *
     * @exception IOException if an input/output error occurs
     */
    public void write(int b) throws IOException {

        if (debug > 1) {
            System.out.println("write "+b+" in CompressionResponseStream ");
        }
        if (closed)
            throw new IOException("Cannot write to a closed output stream");

        if (bufferCount >= buffer.length) {
            flushToGZip();
        }

        buffer[bufferCount++] = (byte) b;

    }


    /**
     * Write <code>b.length</code> bytes from the specified byte array
     * to our output stream.
     *
     * @param b The byte array to be written
     *
     * @exception IOException if an input/output error occurs
     */
    public void write(byte b[]) throws IOException {

        write(b, 0, b.length);

    }


    /**
     * Write <code>len</code> bytes from the specified byte array, starting
     * at the specified offset, to our output stream.
     *
     * @param b The byte array containing the bytes to be written
     * @param off Zero-relative starting offset of the bytes to be written
     * @param len The number of bytes to be written
     *
     * @exception IOException if an input/output error occurs
     */
    public void write(byte b[], int off, int len) throws IOException {

        if (debug > 1) {
            System.out.println("write, bufferCount = " + bufferCount + " len = " + len + " off = " + off);
        }
        if (debug > 2) {
            System.out.print("write(");
            System.out.write(b, off, len);
            System.out.println(")");
        }

        if (closed)
            throw new IOException("Cannot write to a closed output stream");

        if (len == 0)
            return;

        // Can we write into buffer ?
        if (len <= (buffer.length - bufferCount)) {
            System.arraycopy(b, off, buffer, bufferCount, len);
            bufferCount += len;
            return;
        }

        // There is not enough space in buffer. Flush it ...
        flushToGZip();

        // ... and try again. Note, that bufferCount = 0 here !
        if (len <= (buffer.length - bufferCount)) {
            System.arraycopy(b, off, buffer, bufferCount, len);
            bufferCount += len;
            return;
        }

        // write direct to gzip
        writeToGZip(b, off, len);
    }

    public void writeToGZip(byte b[], int off, int len) throws IOException {

        if (debug > 1) {
            System.out.println("writeToGZip, len = " + len);
        }
        if (debug > 2) {
            System.out.print("writeToGZip(");
            System.out.write(b, off, len);
            System.out.println(")");
        }
        if (gzipstream == null) {
            if (debug > 1) {
                System.out.println("new GZIPOutputStream");
            }
            response.addHeader("Content-Encoding", "gzip");
            gzipstream = new GZIPOutputStream(output);
        }
        gzipstream.write(b, off, len);

    }


    // -------------------------------------------------------- Package Methods


    /**
     * Has this response stream been closed?
     */
    public boolean closed() {

        return (this.closed);

    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
奇米综合一区二区三区精品视频 | 91在线porny国产在线看| 成人免费三级在线| 在线观看一区日韩| 91麻豆精品国产91久久久久久| 日韩一级片网站| 国产精品免费久久| 亚洲影视资源网| 欧美三级乱人伦电影| 国产亚洲人成网站| 丝袜美腿高跟呻吟高潮一区| 国产精品一区二区免费不卡| 欧美日韩在线精品一区二区三区激情| 偷拍日韩校园综合在线| av成人老司机| 久久视频一区二区| 日韩精品亚洲一区二区三区免费| 欧美肥妇bbw| 亚洲国产一区在线观看| av成人免费在线| 午夜激情久久久| 久久精品综合网| 91麻豆成人久久精品二区三区| 午夜一区二区三区视频| 99精品欧美一区二区蜜桃免费| 欧美极品另类videosde| 激情综合五月婷婷| 欧美伦理电影网| 丰满岳乱妇一区二区三区| 久久午夜国产精品| 色综合天天狠狠| 中文字幕av在线一区二区三区| 99久久99精品久久久久久| 丝袜美腿亚洲一区| 亚洲视频在线一区二区| 黑人精品欧美一区二区蜜桃| 欧美日韩精品一区二区三区| 亚洲精品美腿丝袜| 在线一区二区三区四区| 一区二区三区四区在线播放| 色哟哟国产精品| 精品夜夜嗨av一区二区三区| 亚洲日穴在线视频| 久久女同互慰一区二区三区| 国产成人小视频| 中国av一区二区三区| 日韩一二三四区| 欧美色图免费看| 色综合视频一区二区三区高清| 久久爱www久久做| 国产精品色婷婷| 日韩精品一区二区三区三区免费| 美女脱光内衣内裤视频久久网站 | 国产午夜精品久久久久久久| 欧美日韩成人在线| 一本大道久久精品懂色aⅴ| 成人一道本在线| 国产一区久久久| 成人免费一区二区三区在线观看| av在线播放一区二区三区| 国产在线播精品第三| 午夜欧美一区二区三区在线播放| 国产精品久久久一本精品 | 国产久卡久卡久卡久卡视频精品| 午夜精品在线看| 亚洲制服欧美中文字幕中文字幕| 中文字幕永久在线不卡| 中文字幕二三区不卡| 国产色婷婷亚洲99精品小说| 久久久综合九色合综国产精品| 日韩免费观看高清完整版| 日韩视频一区二区| 精品少妇一区二区三区免费观看 | ...xxx性欧美| 国产精品久久毛片av大全日韩| 国产精品色婷婷| 亚洲天堂久久久久久久| 日韩美女精品在线| 国产午夜亚洲精品理论片色戒| 久久久久久夜精品精品免费| 久久久久久亚洲综合影院红桃| 国产午夜一区二区三区| 国产精品欧美经典| 亚洲美女精品一区| 日韩视频免费观看高清完整版在线观看| 欧美午夜电影网| 成人精品高清在线| 日韩vs国产vs欧美| 亚洲欧美日韩中文字幕一区二区三区| 中文字幕亚洲不卡| 18欧美亚洲精品| 亚洲夂夂婷婷色拍ww47| 美女网站在线免费欧美精品| 国产一区二区h| 91无套直看片红桃| 欧美精品123区| 久久免费视频一区| 亚洲少妇最新在线视频| 亚洲.国产.中文慕字在线| 日本亚洲视频在线| 国模少妇一区二区三区| 不卡欧美aaaaa| 欧美精品99久久久**| 久久―日本道色综合久久| 成人欧美一区二区三区小说| 亚洲国产综合人成综合网站| 狠狠v欧美v日韩v亚洲ⅴ| www.激情成人| 91麻豆精品国产自产在线| 国产亚洲欧美在线| 亚洲一级二级在线| 国精产品一区一区三区mba视频 | 中文字幕一区av| 欧美国产精品v| 亚洲免费在线视频一区 二区| 亚洲一区二区在线观看视频| 另类欧美日韩国产在线| 99久久婷婷国产| 91精品福利在线一区二区三区 | 水蜜桃久久夜色精品一区的特点| 老司机精品视频在线| 99久久精品国产一区二区三区 | 久久久久久久久蜜桃| 一区二区三区色| 国产又粗又猛又爽又黄91精品| 欧美做爰猛烈大尺度电影无法无天| 日韩免费看网站| 一区av在线播放| 国产成人在线色| 制服丝袜亚洲播放| 亚洲视频在线一区二区| 国内精品写真在线观看| 欧美日韩在线三级| 成人免费在线播放视频| 激情综合色综合久久| 日本乱码高清不卡字幕| 国产女同互慰高潮91漫画| 久久久99精品久久| 午夜精品久久久久久久蜜桃app| 成人av在线观| 国产日本亚洲高清| 免费欧美在线视频| 欧美三级日本三级少妇99| 国产精品美女久久久久久2018| 久久99国产精品久久99果冻传媒| 欧美性生交片4| 日韩一区有码在线| 国产精品中文字幕欧美| 日韩一区二区三免费高清| 亚洲主播在线播放| 日本国产一区二区| 亚洲天堂2014| av在线播放不卡| 欧美激情在线免费观看| 国产精品影音先锋| 久久久影院官网| 狠狠色狠狠色综合日日91app| 欧美一区二区成人6969| 日韩av午夜在线观看| 欧美精品少妇一区二区三区| 亚洲午夜三级在线| 欧美性色黄大片手机版| 一卡二卡欧美日韩| 欧美主播一区二区三区美女| 亚洲激情网站免费观看| 91福利国产精品| 亚洲成人1区2区| 欧美男同性恋视频网站| 日韩国产欧美三级| 欧美一区二区三区视频在线 | 国产乱一区二区| 精品99999| 一区2区3区在线看| 欧美猛男超大videosgay| 亚洲国产精品影院| 91精品啪在线观看国产60岁| 日韩黄色小视频| 欧美xxxxx裸体时装秀| 国模大尺度一区二区三区| 国产视频一区在线播放| 91网站在线观看视频| 亚洲电影你懂得| 精品国精品自拍自在线| 国产成人三级在线观看| 国产精品超碰97尤物18| 欧美自拍偷拍午夜视频| 日韩成人一级片| 国产亚洲一本大道中文在线| 成人永久免费视频| 一区二区三区在线播| 5月丁香婷婷综合| 国内精品在线播放| **网站欧美大片在线观看| 欧美日韩亚洲综合一区| 精品一区二区三区视频 | 日韩精品一区二区三区在线观看| 国产一区二三区| 亚洲特级片在线| 日韩免费高清av| 99re热这里只有精品视频|