Package java.util.zip

Examples of java.util.zip.GZIPOutputStream


         return buffer;
      }
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      byte[] ret = null;
      try {
          GZIPOutputStream zippedStream = new GZIPOutputStream(baos);
          zippedStream.write(buffer);
          zippedStream.finish();
          ret = baos.toByteArray();
          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


    }

    private void setupCompressionOutputStream(StreamMessageContext ctx) {
       
        try {
            ctx.setOutputStream(new GZIPOutputStream(ctx.getOutputStream()));
        } catch (IOException ex) {
            throw new ProtocolException(ex);
        }
    }
View Full Code Here

    // String url = "http://motherlode.ucar.edu:8080/thredds/dodsC/fmrc/NCEP/NDFD/CONUS_5km/NDFD-CONUS_5km_best.ncd";

    StationObsDataset ncd = (StationObsDataset) TypedDatasetFactory.open(FeatureType.STATION, url, null, new StringBuilder());
    StationObsDatasetInfo info = new StationObsDatasetInfo(ncd, null);
    FileOutputStream fos2 = new FileOutputStream("C:/TEMP/stationCollection.xml");
    GZIPOutputStream zout =  new GZIPOutputStream( fos2);
    //info.writeXML(fos2);
    //fos2.close();

    info.writeStationObsDatasetXML(System.out);
    info.writeStationCollectionXML(zout);

    zout.close();
    File f = new File("C:/TEMP/stationCollection.xml");
    System.out.println(" size="+f.length());
  }
View Full Code Here

  void read2xml() throws IOException, XMLStreamException {
    XMLOutputFactory fac = XMLOutputFactory.newInstance();

    String fileout = "D:/bufr/out/test5.xml.gzip";
    FileOutputStream fos = new FileOutputStream(fileout);
    GZIPOutputStream zos = new GZIPOutputStream(fos);

    //staxWriter = fac.createXMLStreamWriter(System.out, "UTF-8");
    //staxWriter = fac.createXMLStreamWriter(fos, "UTF-8");
    staxWriter = fac.createXMLStreamWriter(zos, "UTF-8");

    staxWriter.writeStartDocument("UTF-8", "1.0");
    staxWriter.writeCharacters("\n");
    staxWriter.writeStartElement("bufrMessages");

    String filename = "D:/bufr/mlodeSorted/IUSUV1KWBC.bufr";
    //String filename = "D:/bufr/out/IUACRJTD-1.bufr";
    //String filename = "D:/bufr/mlodeSorted/ISXAB40KWNO.bufr";
    test(filename, new MClosure() {
      public void run(String filename) throws IOException {
        scan(filename);
      }
    });

    staxWriter.writeCharacters("\n");
    staxWriter.writeEndDocument();
    staxWriter.flush();
    zos.close();

    out.flush();
  }
View Full Code Here

      // Write header
      out.write(MAGIC_NUMBER);
      out.write(BMSF_VERSION);

      // The rest of the data is GZIP-compressed
      DataOutputStream dataOut = new DataOutputStream(new GZIPOutputStream(out));
      out = dataOut;

      writeNamespaces(dataOut);

      writeStatements(dataOut);
View Full Code Here

     * @return the compressed byte array
     * @throws IOException if an excption occurs
     */
  public static byte[] compress(byte[] data) throws IOException {
      ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length);
      GZIPOutputStream out = new GZIPOutputStream(bos);
     
        out.write(data);
        out.close();
        return bos.toByteArray();
    }
View Full Code Here

    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

  }

  // test GZIPOutputStream - write 1M random floats
  static public void gzipRandom(String filenameOut, boolean buffer) throws IOException {
    FileOutputStream fout = new FileOutputStream(filenameOut);
    OutputStream out = new GZIPOutputStream(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

    }

    private void setupCompressionOutputStream(StreamMessageContext ctx) {

        try {
            GZIPOutputStream zipOut = new GZIPOutputStream(ctx.getOutputStream());
            ctx.setOutputStream(zipOut);
        } catch (IOException ex) {
            throw new ProtocolException(ex);
        }
    }
View Full Code Here

    }

    protected OutputStream doGetOutputStream(boolean bAppend) throws Exception
    {
        OutputStream os = getContainer().getContent().getOutputStream(false);
        return new GZIPOutputStream(os);
    }
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.