Package java.util.zip

Examples of java.util.zip.GZIPOutputStream


            parent.mkdirs();
        }
        if (!file.createNewFile()) {
            throw new IOException("Attempt to overwrite file: " + file);
        }
        return new GZIPOutputStream(new FileOutputStream(file));
    }
View Full Code Here


        response.setStatus(HTTP_OK);
        if (!"gzip".equals(request.getHeader("Accept-Encoding")))
          return;

        response.setHeader("Content-Encoding", "gzip");
        GZIPOutputStream output;
        try {
          output = new GZIPOutputStream(response.getOutputStream());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
        try {
          output.write("hello compressed".getBytes(CHARSET_UTF8));
        } catch (IOException e) {
          throw new RuntimeException(e);
        } finally {
          try {
            output.close();
          } catch (IOException ignored) {
            // Ignored
          }
        }
      }
View Full Code Here

            if (dump != null) {
                if (supportsGzip) {
                    response.setHeader("Content-Encoding", "gzip");
                    response.setHeader("Content-Type", "text/html; charset=UTF-8");
                    try {
                        GZIPOutputStream gzos = new GZIPOutputStream(response.getOutputStream());
                        gzos.write(dump.getBytes("UTF-8"));
                        gzos.close();
                    } catch (IOException ie) {
                        // handle the error here
                        ie.printStackTrace();
                    }
                } else {
View Full Code Here

                log.trace("{} Written with gzip compression", httpRequest.getRequestURL());
            }

            // Create a gzip stream
            final ByteArrayOutputStream compressed = new ByteArrayOutputStream();
            final GZIPOutputStream gzout = new GZIPOutputStream(compressed);

            // Handle the request
            final GZipServletResponseWrapper wrapper = new GZipServletResponseWrapper(httpResponse, gzout);
            wrapper.setDisableFlushBuffer(true);
            chain.doFilter(request, wrapper);
            wrapper.flush();

            gzout.close();

            // double check one more time before writing out
            // repsonse might have been committed due to error
            if (response.isCommitted()) {
                return;
View Full Code Here

    public void testDecompressGzip() throws IOException {

        String testString = "Teststring 123";

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        GZIPOutputStream gzip = new GZIPOutputStream(out);
        gzip.write(testString.getBytes());
        gzip.close();

        byte[] buffer = out.toByteArray();

        assertEquals(testString, Tools.decompressGzip(buffer));
    }
View Full Code Here

    LOG.info(crawl.size() + " tweets fetched in " + duration + "ms");

    LOG.info("Writing tweets...");
    int written = 0;

    OutputStreamWriter out = new OutputStreamWriter(new GZIPOutputStream(
        new FileOutputStream(output)), "UTF-8");
    for (Map.Entry<Long, String> entry : crawl.entrySet()) {
      written++;
      out.write(entry.getValue() + "\n");
    }
View Full Code Here

                temp = new File((String) options.valueOf("test-gz"));
            } else {
                temp = File.createTempFile("json-data", ".txt.gz", workingDir);
                temp.deleteOnExit();
                System.out.println("Generating test data in " + temp);
                OutputStream outputStream = new GZIPOutputStream(new FileOutputStream(temp));
                Writer writer = new BufferedWriter(new OutputStreamWriter(outputStream),
                                                   10 * 1024 * 1024);
                String value = TestUtils.randomLetters(valueSize);
                for(int i = 0; i < numValues; i++) {
                    writer.write("\"");
View Full Code Here

    public void run()
    {
        if (action == SAVE) {
            try {
                PrintStream out = new PrintStream(new GZIPOutputStream(
                        new FileOutputStream(file)), false, Constantes.ASI_ENCODING);

                out.println("<?xml version=\"1.0\" encoding=\"" + Constantes.ASI_ENCODING + "\"?>");
                out.println("<analyse>");
View Full Code Here

*/
public class GzipCompressionStrategy extends StreamCompressionStrategy {

    @Override
    protected OutputStream wrapOutputStream(OutputStream underlying) throws IOException {
        return new GZIPOutputStream(underlying);
    }
View Full Code Here

 
  public boolean exportJS(String outputFile, boolean decode, boolean gzip, boolean preamble, boolean info,
          String rootElementName) throws Exception {
    OutputStream out;
    if (gzip) {
      out = new GZIPOutputStream(new FileOutputStream(outputFile));
    } else {
      out = new FileOutputStream(outputFile);
    }
    return export(out, decode, preamble, info, rootElementName, null);
  }
View Full Code Here

TOP

Related Classes of java.util.zip.GZIPOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.