Package java.util.zip

Examples of java.util.zip.GZIPOutputStream


     
      if ( HTTPUtils.canGZIP(accept_encoding)){

        is_gzipped = true;
       
        os = new GZIPOutputStream(os);
       
        header_map.put("Content-Encoding", "gzip");
      }
    }
   
View Full Code Here


    }
    OutputStream out = null;
    InputStream in = null;
    try {
      if (!headOnly) {
        out = doCompress ? new GZIPOutputStream(res.getOutputStream()) : (OutputStream) res.getOutputStream();
        // Check throttle.
        if (throttleTab != null) {
          ThrottleItem throttleItem = (ThrottleItem) throttleTab.get(path);
          if (throttleItem != null) {
            // !!! Need to count for multiple simultaneous fetches.
View Full Code Here

    if(gzip && packet.supports(MessageContext.SERVLET_REQUEST) &&
        isGzipInRequest((HttpServletRequest)packet.get(MessageContext.SERVLET_REQUEST))){
      HttpServletResponse response = (HttpServletResponse)packet.get(MessageContext.SERVLET_RESPONSE);
      if(!response.isCommitted()){
        response.addHeader("Content-Encoding", "gzip");
        out = new GZIPOutputStream(out);
      }
    }
    try {
      // MessageContext.MESSAGE_OUTBOUND_PROPERTY set by JAX_WS only if handler configured. But encode always a out bound.
      packet.invocationProperties.put(MessageContext.MESSAGE_OUTBOUND_PROPERTY,true);
View Full Code Here

        try {
            tarFile = archiveAction.getArchivePath();
            OutputStream outStr = new FileOutputStream(tarFile);
            switch (archiveAction.getCompression()) {
                case GZIP:
                    outStr = new GZIPOutputStream(outStr);
                    break;
                case BZIP2:
                    outStr.write('B');
                    outStr.write('Z');
                    outStr = new CBZip2OutputStream(outStr);
View Full Code Here

    final byte[] b = new byte[(int) Size.OneMeg.bytes()];

    final InputStream in = new FileInputStream(src);

    final GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(dst));

    int length = 0;
    while ((length = in.read(b)) != -1) {
      out.write(b, 0, length);
    }

    in.close();
    out.close();
  }
View Full Code Here

    @Override
    public void close() throws IOException {
        if (bufferedOutput instanceof ByteArrayOutputStream) {
            ByteArrayOutputStream compressedContent = new ByteArrayOutputStream();
            GZIPOutputStream gzipstream = new GZIPOutputStream(compressedContent);
            gzipstream.write(((ByteArrayOutputStream) bufferedOutput).toByteArray());
            gzipstream.finish();
            byte[] compressedBytes = compressedContent.toByteArray();
            response.setContentLength(compressedBytes.length);
            response.addHeader("Content-Encoding", "gzip");
            output.write(compressedBytes);
        } else ((GZIPOutputStream) bufferedOutput).finish();
View Full Code Here

    private void checkBufferSize(int length) throws IOException {
        if (bufferedOutput instanceof ByteArrayOutputStream) {
            ByteArrayOutputStream baos = (ByteArrayOutputStream) bufferedOutput;
            if (baos.size() + length > bufferSize) {
                response.addHeader("Content-Encoding", "gzip");
                bufferedOutput = new GZIPOutputStream(output);
                bufferedOutput.write(baos.toByteArray());
            }
        }
    }
View Full Code Here

    @Override
    public void close() throws IOException {
        if (bufferedOutput instanceof ByteArrayOutputStream) {
            ByteArrayOutputStream compressedContent = new ByteArrayOutputStream();
            GZIPOutputStream gzipstream = new GZIPOutputStream(compressedContent);
            gzipstream.write(((ByteArrayOutputStream) bufferedOutput).toByteArray());
            gzipstream.finish();
            byte[] compressedBytes = compressedContent.toByteArray();
            response.setContentLength(compressedBytes.length);
            response.addHeader("Content-Encoding", "gzip");
            output.write(compressedBytes);
        } else ((GZIPOutputStream) bufferedOutput).finish();
View Full Code Here

    private void checkBufferSize(int length) throws IOException {
        if (bufferedOutput instanceof ByteArrayOutputStream) {
            ByteArrayOutputStream baos = (ByteArrayOutputStream) bufferedOutput;
            if (baos.size() + length > bufferSize) {
                response.addHeader("Content-Encoding", "gzip");
                bufferedOutput = new GZIPOutputStream(output);
                bufferedOutput.write(baos.toByteArray());
            }
        }
    }
View Full Code Here

         return buffer;
      }
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      byte[] ret = null;
      try {
          GZIPOutputStream zippedStream = new GZIPOutputStream(baos);
          ObjectOutputStream objectOutputStream = new ObjectOutputStream(zippedStream);
          objectOutputStream.writeObject(buffer);
          objectOutputStream.flush();
          zippedStream.finish();
          ret = baos.toByteArray();
          objectOutputStream.close();
          if (ret.length >= uncompressedLength) {
             log.fine("The compressed size is bigger than the original. Will not compress since it does not make sense");
             return buffer;
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.