集册 Java实例教程 为HttpServletResponse返回gziping PrintWriter

为HttpServletResponse返回gziping PrintWriter

欢马劈雪     最近更新时间:2020-01-02 10:19:05

590
为HttpServletResponse返回gziping PrintWriter
/* 来 自 时代Java - nowjava.com*/

import java.io.IOException;

import java.io.PrintWriter;

import java.util.zip.GZIPOutputStream;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;


public class Main{

    /** Return gzipping PrintWriter for response */

    public static PrintWriter getGzipWriter(HttpServletResponse response)

            throws IOException {


        return (new PrintWriter(new GZIPOutputStream(

                response.getOutputStream())));


    }

}