Package java.util.zip

Examples of java.util.zip.DeflaterOutputStream


            } else if ("ZIP".equals(compressionAlgorithm)) {
                ZipOutputStream z = new ZipOutputStream(out);
                z.putNextEntry(new ZipEntry(entryName));
                out = z;
            } else if ("DEFLATE".equals(compressionAlgorithm)) {
                out = new DeflaterOutputStream(out);
            } else if ("LZF".equals(compressionAlgorithm)) {
                out = new LZFOutputStream(out);
            } else if (compressionAlgorithm != null) {
                throw DbException.get(ErrorCode.UNSUPPORTED_COMPRESSION_ALGORITHM_1, compressionAlgorithm);
            }
View Full Code Here


     */
    public static synchronized String compress( final String data ) {

        ByteArrayOutputStream byteOut = new ByteArrayOutputStream( 512 );
        Deflater deflater = new Deflater();
        DeflaterOutputStream oStream = new DeflaterOutputStream( byteOut, deflater );

        try {
            oStream.write( data.getBytes( CONVERTER_UTF8 ) );
            oStream.flush();
            oStream.close();
        } catch (UnsupportedEncodingException e) {
            throw new IllegalArgumentException( "Unsupported encoding exception :" + e.getMessage(), e);
        } catch (IOException e) {
            throw new IllegalStateException( "io error :" + e.getMessage(), e);
        }
View Full Code Here

                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                OutputStream out;

                w.writeAttribute("encoding", "base64");

                DeflaterOutputStream dos;
                if (compressLayerData) {
                    if (Settings.LAYER_COMPRESSION_METHOD_ZLIB.equalsIgnoreCase(settings.layerCompressionMethod)) {
                        dos = new DeflaterOutputStream(baos);
                    } else if (Settings.LAYER_COMPRESSION_METHOD_GZIP.equalsIgnoreCase(settings.layerCompressionMethod)) {
                        dos = new GZIPOutputStream(baos);
                    } else {
                        throw new IOException("Unrecognized compression method \"" + settings.layerCompressionMethod + "\" for map layer " + l.getName());
                    }
                    out = dos;
                    w.writeAttribute("compression", settings.layerCompressionMethod);
                } else {
                    out = baos;
                }

                for (int y = 0; y < l.getHeight(); y++) {
                    for (int x = 0; x < l.getWidth(); x++) {
                        Tile tile = tl.getTileAt(x + bounds.x,
                                                 y + bounds.y);
                        int gid = 0;

                        if (tile != null) {
                            gid = getGid(tile);
                        }

                        out.write(gid       & LAST_BYTE);
                        out.write(gid >> & LAST_BYTE);
                        out.write(gid >> 16 & LAST_BYTE);
                        out.write(gid >> 24 & LAST_BYTE);
                    }
                }

                if (compressLayerData && dos != null) {
                    dos.finish();
                }

                w.writeCDATA(Base64.encodeToString(baos.toByteArray(), true));
            } else {
                for (int y = 0; y < l.getHeight(); y++) {
View Full Code Here

            break;
        case ZIP:
            zOut = new ZipOutputStream(new FileOutputStream(src));
            break;
        case Z0P_GZ:
            zOut = new ZipOutputStream(new DeflaterOutputStream(new FileOutputStream(src)));
            zOut.setLevel(0);
            break;
        }

    }
View Full Code Here

            ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
            OutputStream os = bytesOut;
            ActiveMQConnection connection = getConnection();
            if (connection != null && connection.isUseCompression()) {
                compressed = true;
                os = new DeflaterOutputStream(os);
            }
            DataOutputStream dataOut = new DataOutputStream(os);
            MarshallingSupport.writeUTF8(dataOut, text);
            dataOut.close();
            setContent(bytesOut.toByteSequence());
View Full Code Here

                ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
                OutputStream os = bytesOut;
                ActiveMQConnection connection = getConnection();
                if (connection != null && connection.isUseCompression()) {
                    compressed = true;
                    os = new DeflaterOutputStream(os);
                }
                DataOutputStream dataOut = new DataOutputStream(os);
                ObjectOutputStream objOut = new ObjectOutputStream(dataOut);
                objOut.writeObject(object);
                objOut.flush();
View Full Code Here

        nbrEntries ++;
        dosZipSources[i].close();
        long startTime = System.currentTimeMillis();
        int zipBufSize = Math.max(1024, baos.size() / 100);
        deflater.reset();
        DeflaterOutputStream cds = new DeflaterOutputStream(baosZipped, deflater, zipBufSize);      
        baos.writeTo(cds);
        cds.close();
        idxAndLen.add(i);
        if (doMeasurements) {
          idxAndLen.add((int)(sm.statDetails[i].afterZip = deflater.getBytesWritten()));           
          idxAndLen.add((int)(sm.statDetails[i].beforeZip = deflater.getBytesRead()));
          sm.statDetails[i].zipTime = System.currentTimeMillis() - startTime;
View Full Code Here

        }
    }

    protected byte[] compress(byte[] bytes, int offset, int length) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        DeflaterOutputStream  deflater = new DeflaterOutputStream( out );
        deflater.write(bytes, offset, length);
        deflater.close();
        return out.toByteArray();
    }
View Full Code Here

          nbrEntries ++;
          dosZipSources[i].close();
          long startTime = System.currentTimeMillis();
          int zipBufSize = Math.max(1024, baos.size() / 100);
          deflater.reset();
          DeflaterOutputStream cds = new DeflaterOutputStream(baosZipped, deflater, zipBufSize);      
          baos.writeTo(cds);
          cds.close();
          idxAndLen.add(i);
          if (doMeasurement) {
            idxAndLen.add((int)(sm.statDetails[i].afterZip = deflater.getBytesWritten()));           
            idxAndLen.add((int)(sm.statDetails[i].beforeZip = deflater.getBytesRead()));
            sm.statDetails[i].zipTime = System.currentTimeMillis() - startTime;
View Full Code Here

    try
    {
      final MemoryByteArrayOutputStream out =
          new MemoryByteArrayOutputStream(INITIAL_BUFFER_SIZE, 256 * INITIAL_BUFFER_SIZE);
      final DeflaterOutputStream deflateOut = new DeflaterOutputStream(out);
      final OutputStreamWriter xmlBuffer = new OutputStreamWriter(deflateOut, "UTF-16");
      //    final StringWriter xmlBuffer = new StringWriter
      //        (OfficeDocumentReportTarget.INITIAL_BUFFER_SIZE);
      final XmlWriter contentXmlWriter = new XmlWriter(xmlBuffer, createTagDescription());
      contentXmlWriter.copyNamespaces(currentWriter);
View Full Code Here

TOP

Related Classes of java.util.zip.DeflaterOutputStream

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.