Examples of DeflaterOutputStream


Examples of java.util.zip.DeflaterOutputStream

    }
   
    Deflater deflater = new Deflater( Deflater.DEFAULT_COMPRESSION );
      ByteArrayOutputStream outBytes = new ByteArrayOutputStream((width+1)*height);
             
      DeflaterOutputStream compBytes = new DeflaterOutputStream( outBytes, deflater );
      try {
        compBytes.write(payload);
        compBytes.close();
      } catch(Exception e) {
        e.printStackTrace();
      }
      byte[] compPayload = outBytes.toByteArray();
         
View Full Code Here

Examples of java.util.zip.DeflaterOutputStream

     * @exception IOException on error
     */
    public void writeStream(OutputStream os) throws IOException {
        if(deflate) {
            ByteArrayOutputStream b = new ByteArrayOutputStream();
            DeflaterOutputStream dos = new DeflaterOutputStream(b);
            //,new Deflater(Deflater.BEST_COMPRESSION,true));
            buf.writeTo(dos);
            dos.finish();
            dos.close();
           
            // FlatDecode is compatible with the java.util.zip.Deflater class
            os.write("/Filter /FlateDecode\n".getBytes());
            os.write("/Length ".getBytes());
            os.write(Integer.toString(b.size()+1).getBytes());
View Full Code Here

Examples of java.util.zip.DeflaterOutputStream

    return f.length() / (1000 * 1000);
  }

  double copyFileZipped(File f) throws IOException {
    Socket s = new Socket(host, port);
    OutputStream out = new BufferedOutputStream( new DeflaterOutputStream( s.getOutputStream()), bufferSize);
    ucar.nc2.util.IO.copyFileB(f, out, bufferSize);
    out.close();
    return f.length() / (1000 * 1000);
  }
View Full Code Here

Examples of java.util.zip.DeflaterOutputStream

    FileInputStream fin = new FileInputStream(filenameIn);
    InputStream in = new BufferedInputStream(fin, 1000);

    FileOutputStream fout = new FileOutputStream(filenameOut);
    OutputStream out = (inflate) ? new DeflaterOutputStream(fout) : new GZIPOutputStream(fout);
    out = new BufferedOutputStream(out, 1000);

    long start = System.currentTimeMillis();
    IO.copyB( in, out, 10000);
    out.flush();
View Full Code Here

Examples of java.util.zip.DeflaterOutputStream

  }

  // test DeflaterOutputStream - write 1M random floats
  static public void deflateRandom( String filenameOut, boolean buffer) throws IOException {
    FileOutputStream fout = new FileOutputStream(filenameOut);
    OutputStream out = new DeflaterOutputStream(fout);
    if (buffer)
      out = new BufferedOutputStream(out, 1000); // 3X performance by having this !!
    DataOutputStream dout = new DataOutputStream(out);

    Random r = new Random();
View Full Code Here

Examples of java.util.zip.DeflaterOutputStream

    String filenameOut = "C:/temp/tempFile2.compress2";

    FileInputStream fin = new FileInputStream(filenameIn);
    FileOutputStream fout = new FileOutputStream(filenameOut);
    BufferedOutputStream bout = new BufferedOutputStream(fout, 10 * 1000);
    DeflaterOutputStream out = new DeflaterOutputStream(fout);

    long start = System.currentTimeMillis();
    IO.copyB(fin, out, 10 * 1000);
    double took = .001 * (System.currentTimeMillis() - start);
    System.out.println(" that took = "+took+"sec");
View Full Code Here

Examples of java.util.zip.DeflaterOutputStream

                    SerializeAdapter adpt = adapters[i];
                    try
                    {
                        if ( runs == 1 || runs == 3 )
                        {
                            DeflaterOutputStream sOut = new GZIPOutputStream( bOut, EJConstants.BUFFERED_STREAM_SIZE )
                                {
                                    {
                                        def.setLevel( EJConstants.DEFAULT_COMPRESSION_LEVEL );
                                    }
                                };
                            adpt.write( new ObjectBean(), sOut );
                            sOut.finish();
                            sOut.close();
                        }
                        else
                        {
                            adpt.write( new ObjectBean(), bOut );
                        }
View Full Code Here

Examples of java.util.zip.DeflaterOutputStream

      CacheKey key = new CacheKey(perception.typePerception, perception.zoneid, perception.protocolVersion);

      if (!cachedContent.containsKey(key)) {
        logger.debug("Perception not found in cache");
        ByteArrayOutputStream array = new ByteArrayOutputStream();
        DeflaterOutputStream out_stream = new DeflaterOutputStream(array);
        OutputSerializer serializer = new OutputSerializer(out_stream);
        serializer.setProtocolVersion(perception.getProtocolVersion());

        perception.computeStaticPartPerception(serializer);
        out_stream.close();
        byte[] content = array.toByteArray();

        cachedContent.put(key, content);
      } else {
        logger.debug("Perception FOUND in cache");
View Full Code Here

Examples of java.util.zip.DeflaterOutputStream

  @Override
  public void writeObject(marauroa.common.net.OutputSerializer out) throws IOException {
    super.writeObject(out);

    ByteArrayOutputStream array = new ByteArrayOutputStream();
    DeflaterOutputStream out_stream = new DeflaterOutputStream(array);
    OutputSerializer serializer = new OutputSerializer(out_stream);
    serializer.setProtocolVersion(out.getProtocolVersion());

    int size = contents.size();
    serializer.write(size);

    for (TransferContent content : contents) {
      content.writeFULL(serializer);
    }

    out_stream.close();

    out.write(array.toByteArray());
  }
View Full Code Here

Examples of java.util.zip.DeflaterOutputStream

   * @throws IOException in case of an input/output error
   * @throws SQLException in case of an database error
   */
  public int storeRPObject(DBTransaction transaction, RPObject object) throws IOException, SQLException {
    ByteArrayOutputStream array = new ByteArrayOutputStream();
    DeflaterOutputStream out_stream = new DeflaterOutputStream(array);
    OutputSerializer serializer = new OutputSerializer(out_stream);
    int protocolVersion = serializer.getProtocolVersion();

    try {
      object.writeObject(serializer, DetailLevel.FULL);
      out_stream.close();
    } catch (IOException e) {
      logger.warn("Error while serializing rpobject: " + object, e);
      throw e;
    }

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.