Examples of FastByteArrayOutputStream


Examples of org.elasticsearch.hadoop.util.FastByteArrayOutputStream

    private static FastByteArrayOutputStream out;

    @BeforeClass
    public static void beforeClass() {
        out = new FastByteArrayOutputStream();
    }
View Full Code Here

Examples of org.elasticsearch.hadoop.util.FastByteArrayOutputStream

    private static FastByteArrayOutputStream out;

    @BeforeClass
    public static void beforeClass() {
        out = new FastByteArrayOutputStream();
    }
View Full Code Here

Examples of org.oxbow.swingbits.util.copy.FastByteArrayOutputStream

    public static final <T extends Serializable> FastByteArrayOutputStream store( T obj ) {

      try {

        FastByteArrayOutputStream fbos = new FastByteArrayOutputStream();
          ObjectOutputStream out = new ObjectOutputStream(fbos);
          out.writeObject( obj );
          out.flush();
          out.close();
View Full Code Here

Examples of winterwell.utils.io.FastByteArrayOutputStream

   * @param object
   * @return a copy of object, which should share no structure
   * @testedby {@link UtilsTest#testCopy()}
   */
  public static <X> X copy(X object) {
    FastByteArrayOutputStream out = new FastByteArrayOutputStream();
    XStreamUtils.xstream().toXML(object, out);
    FastByteArrayInputStream in = new FastByteArrayInputStream(
        out.getByteArray(), out.getSize());
    Object copy = XStreamUtils.xstream().fromXML(in);
    return (X) copy;
  }
View Full Code Here

Examples of xbird.util.io.FastByteArrayOutputStream

        this._exprBytes = b;
    }

    public static byte[] toBytes(final BindingVariable bindingVar, final XQExpression bodyExpr) {
        final FastByteArrayOutputStream bos = new FastByteArrayOutputStream(8192);
        try {
            final ObjectOutputStream oos = new ObjectOutputStream(bos);
            oos.writeObject(bodyExpr);
            oos.writeObject(bindingVar);
            oos.flush();
        } catch (IOException e) {
            LOG.error(e.getMessage(), e);
            throw new IllegalStateException(e);
        }
        return bos.toByteArray();
    }
View Full Code Here

Examples of xbird.util.io.FastByteArrayOutputStream

* @author Makoto YUI (yuin405+xbird@gmail.com)
*/
public class SerializationTest extends TestCase {

    public void test1() throws IOException, ClassNotFoundException {
        FastByteArrayOutputStream f = new FastByteArrayOutputStream();

        ObjectOutputStream out = new ObjectOutputStream(f);
        Student student1 = new Student("Chris", "Giroir", "111111", "elkfjwe", "wifjew");
        out.writeObject(student1);
        out.writeInt(5);
        out.close();

        out = new NoHeaderObjectOutputStream(f);
        Student student2 = new Student("Chris2", "Giroir2", "elkfjwe", "111111");
        out.writeObject(student2);
        out.close();

        final byte[] b = f.toByteArray();

        FastByteArrayInputStream in = new FastByteArrayInputStream(b);
        ObjectInputStream oin = new ObjectInputStream(in);

        Assert.assertEquals(student1, oin.readObject());
View Full Code Here

Examples of xbird.util.io.FastByteArrayOutputStream

        oin.close();
    }

    public void test2() throws IOException, ClassNotFoundException {
        FastByteArrayOutputStream f = new FastByteArrayOutputStream();

        ObjectOutputStream out = new ObjectOutputStream(f);
        Student student1 = new Student("Chris", "Giroir", "111111", "elkfjwe", "wifjew");
        out.writeObject(student1);
        out.writeInt(5);

        FastByteArrayOutputStream out2 = new FastByteArrayOutputStream();
        ObjectOutputStream oos2 = new ObjectOutputStream(out2);
        Student student2 = new Student("Chris2", "Giroir2", "elkfjwe", "111111");
        Student student3 = new Student("dsfsfsd", "sasa", "DSsd", "sds");
        oos2.writeObject(student2);
        oos2.writeObject(student3);

        byte[] b2 = out2.toByteArray();
        out.writeInt(b2.length);
        out.write(b2);

        FastByteArrayInputStream bis3 = new FastByteArrayInputStream(b2);
        ObjectInputStream ois3 = new ObjectInputStream(bis3);
View Full Code Here

Examples of xbird.util.io.FastByteArrayOutputStream

        oin.close();
    }

    public void testPlaceHolder1() throws IOException, ClassNotFoundException {
        FastByteArrayOutputStream f = new FastByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(f);
        PlaceHolder holder1 = new PlaceHolder();
        out.writeObject(holder1);
        out.flush();

        FastByteArrayInputStream bis = new FastByteArrayInputStream(f.getInternalArray(), 0, f.size());
        ObjectInputStream ois = new ObjectInputStream(bis);
        Assert.assertEquals(holder1, ois.readObject());
    }
View Full Code Here

Examples of xbird.util.io.FastByteArrayOutputStream

        }

        private byte[] ser() throws IOException {
            student2 = new Student("Chris2", "Giroir2", "elkfjwe", "111111");
            student3 = new Student("dsfsfsd", "sasa", "DSsd", "sds");
            FastByteArrayOutputStream out2 = new FastByteArrayOutputStream();
            ObjectOutputStream oos2 = new ObjectOutputStream(out2);
            oos2.writeObject(student2);
            oos2.writeObject(student3);
            return out2.toByteArray();
        }
View Full Code Here

Examples of xbird.util.io.FastByteArrayOutputStream

    public static byte[] compress(final char[] input) {
        int n = input.length;
        int bitwidth = estimateAdequateBitWidth(input, n);
        CompressedSegment segment = new CompressedSegment(bitwidth);
        compress(input, n, segment);
        FastByteArrayOutputStream bos = new FastByteArrayOutputStream(4096);
        DataOutputStream dos = new DataOutputStream(bos);
        try {
            segment.writeTo(dos);
            dos.flush();
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
        byte[] b = bos.toByteArray();
        return b;
    }
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.