Package java.io

Examples of java.io.ByteArrayOutputStream.reset()


    ByteArrayOutputStream baos = new ByteArrayOutputStream(10000);
    // warm up
    for (int i = 0; i < 15; i++) {
      // a simple loop without templating
      baos.reset();
      StringBuffer sb = new StringBuffer(1000);
      for (Post pp : posts) {
        sb.append("你");
        sb.append("Title: " + pp.getTitle());
        sb.append("Author name: " + pp.getAuthor().name);
View Full Code Here


    }

    long tt = System.currentTimeMillis();
    for (int i = 0; i < 100; i++) {
      // a simple loop without templating
      baos.reset();
      long t = System.currentTimeMillis();
      // StringBuffer sb = new StringBuffer(1000);
      StringBuilder sb = new StringBuilder(1000);
      // StringBundler sb = new StringBundler();
      for (Post pp : posts) {
View Full Code Here

    te = new Posts();
    te.render("抬头", posts);
    baos.write(te.toString().getBytes("UTF-8"));
    baos.write(te.toString().getBytes("UTF-8"));
    for (int i = 0; i < 1000; i++) {
      baos.reset();
      long t = System.currentTimeMillis();
      // System.out.println("run templating: " + i);
      /* Merge data-model with template */

      // StringWriter out = new StringWriter(1000);
View Full Code Here

    baos.write(ba);
    baos.write(ba);
    Charset UTF8 = Charset.forName("UTF-8");
    for (int i = 0; i < 1000; i++) {
      {
        baos.reset();
        long t0 = System.nanoTime();
        baos.write(ba);
        t1 += System.nanoTime() - t0;
      }
      {
View Full Code Here

        long t0 = System.nanoTime();
        baos.write(ba);
        t1 += System.nanoTime() - t0;
      }
      {
        baos.reset();
        long t0 = System.nanoTime();
        // baos.write(ss.getBytes(UTF8));
        baos.write(ss.getBytes("UTF-8")); // seems to be faster than
        // using the Charset object?
        t2 += System.nanoTime() - t0;
View Full Code Here

    baos.write(src.getBytes("UTF-8"));
    baos.write(src.getBytes("UTF-8"));
   
    for (int i = 0; i < 200; i++) {
      {
        baos.reset();
        long t = System.nanoTime();
        bb = StringUtils.encodeUTF8(src);
        byte[] array = bb.array();
        int p = bb.position();
        baos.write(array, 0, p);
View Full Code Here

        int p = bb.position();
        baos.write(array, 0, p);
        t1 += System.nanoTime() - t;
      }
      {
        baos.reset();
        long t = System.nanoTime();
        baos.write(src.getBytes("UTF-8"));
        t2 += System.nanoTime() - t;
      }
    }
View Full Code Here

            compositeTH1.close();
        }
        logger.info(baos.toString());
        Assert.assertEquals("Unexpected number of triples.", EXPECTED_TRIPLES, cth1.getCount() );

        baos.reset();
        CountingTripleHandler cth2 = new CountingTripleHandler();
        NTriplesWriter ctw2 = new NTriplesWriter(baos);
        CompositeTripleHandler compositeTH2 = new CompositeTripleHandler();
        compositeTH2.addChild(cth2);
        compositeTH2.addChild(ctw2);
View Full Code Here

        );
        compositeTH1.close();
        logger.debug("Out1: " + baos.toString());
        Assert.assertEquals("Unexpected number of triples.", EXPECTED_TRIPLES + 3, cth1.getCount() );

        baos.reset();
        CountingTripleHandler cth2 = new CountingTripleHandler();
        NTriplesWriter ctw2 = new NTriplesWriter(baos);
        CompositeTripleHandler compositeTH2 = new CompositeTripleHandler();
        compositeTH2.addChild(cth2);
        compositeTH2.addChild(ctw2);
View Full Code Here

                final byte ch = inbuf[i];
                switch (ch) {
                case '\n':
                    seenCR = false; // swallow CR before LF
                    listener.handle(new String(lineBuf.toByteArray(), cset));
                    lineBuf.reset();
                    rePos = pos + i + 1;
                    break;
                case '\r':
                    if (seenCR) {
                        lineBuf.write('\r');
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.