Package java.io

Examples of java.io.ObjectOutputStream


    if (size <= 0)
      throw new IllegalArgumentException("Buffer size <= 0");
    buf = new byte[size];

    if (! compressedFlows)
      oos = new ObjectOutputStream(this);
    count = 0;
  }
View Full Code Here


          // Writes a serializable object to this output stream.
          if (compressedFlows) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            GZIPOutputStream gzipos = new GZIPOutputStream(baos);
           
            oos = new ObjectOutputStream(gzipos);
            oos.writeObject(msg.not);

            // Be careful, the reset writes a TC_RESET byte
            oos.reset();
            // The OOS flush call the flush of this output stream.
View Full Code Here

                         String dirName, String name,
                         boolean first) throws IOException {
    Context ctx = (Context) perThreadContext.get();
    if (ctx.oos == null) {
      ctx.bos.reset();
      ctx.oos = new ObjectOutputStream(ctx.bos);
    } else {
      ctx.oos.reset();
      ctx.bos.reset();
      ctx.bos.write(OOS_STREAM_HEADER, 0, 4);
    }
View Full Code Here

  public void save(Serializable obj,
                   String dirName, String name,
                   boolean first) throws IOException {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(obj);
    oos.flush();
    saveByteArray(bos.toByteArray(), dirName, name);
  }
View Full Code Here

        System.out.println(xml2);
       
        assertEquals(xml, xml2);
       
        // test serialization of process elements
        new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(process);
    }
View Full Code Here

    public static StatefulSession getSerialisedStatefulSession(StatefulSession session,
                                                               RuleBase ruleBase,
                                                               boolean dispose) throws Exception {
        // Serialize to a byte array
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream( bos );
        out.writeObject( session );
        out.close();
        bos.close();

        // Get the bytes of the serialized object
        final byte[] b1 = bos.toByteArray();

        ByteArrayInputStream bais = new ByteArrayInputStream( b1 );
        StatefulSession session2 = ruleBase.newStatefulSession( bais );
        bais.close();

        bos = new ByteArrayOutputStream();
        out = new ObjectOutputStream( bos );
        out.writeObject( session2 );
        out.close();
        bos.close();

        final byte[] b2 = bos.toByteArray();

        // bytes should be the same.
View Full Code Here

      try {
  OutputStream os = new FileOutputStream(sFile);
  if (sFile.getName().endsWith(".gz")) {
    os = new GZIPOutputStream(os);
  }
  ObjectOutputStream objectOutputStream = new ObjectOutputStream(os);
  objectOutputStream.writeObject(classifier);
  if (trainHeader != null) objectOutputStream.writeObject(trainHeader);
  objectOutputStream.flush();
  objectOutputStream.close();
      } catch (Exception e) {
 
  JOptionPane.showMessageDialog(null, e, "Save Failed",
              JOptionPane.ERROR_MESSAGE);
  saveOK = false;
View Full Code Here

    }

    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

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);
View Full Code Here

    }

    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);
View Full Code Here

TOP

Related Classes of java.io.ObjectOutputStream

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.