List of usage examples for org.apache.commons.io.output CountingOutputStream resetCount
public synchronized int resetCount()
From source file:org.shaman.database.Benchmark.java
/** * prints the file size//from w ww .j a v a 2 s . c o m * @param roots the roots from the different passes */ private void printFileSizes(Record... roots) throws IOException { //result array int size; String format = "%1$,11d"; System.out.println("passes database serial compressed xml"); //save it for (int i = 0; i < roots.length; i++) { Record root = roots[i]; System.out.print("pass " + (i + 1) + " "); //database ArrayOutput ao = new ArrayOutput(); Database db = new Database(root); db.save(ao, FailOnErrorHandler.INSTANCE); size = ao.getTotalSize(); System.out.printf(format, size); System.out.print("B "); //uncompressed serialization CountingOutputStream out = new CountingOutputStream(new NullOutputStream()); ObjectOutputStream dos = new ObjectOutputStream(out); dos.writeObject(root); dos.flush(); size = out.getCount(); System.out.printf(format, size); System.out.print("B "); //compressed serialization out.resetCount(); dos = new ObjectOutputStream(new GZIPOutputStream(out)); dos.writeObject(root); dos.flush(); size = out.getCount(); System.out.printf(format, size); System.out.print("B "); //xml out.resetCount(); XMLEncoder xml = new XMLEncoder(out); xml.writeObject(root); xml.flush(); size = out.getCount(); System.out.printf(format, size); System.out.println("B"); } }