Return gzipping PrintWriter for HttpServletResponse - Java File Path IO

Java examples for File Path IO:GZIP

Description

Return gzipping PrintWriter for HttpServletResponse

Demo Code


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())));

    }/*from   w  w  w .ja  v a  2s  . c o  m*/
}

Related Tutorials