Package java.io

Examples of java.io.ObjectOutputStream$PutField


        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


        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

            data[i] = new Data(i);
            list1.add(data[i]);
        }

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(list1);

        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        ObjectInputStream ois = new ObjectInputStream(bais);

        TLinkedList list2 = (TLinkedList) ois.readObject();
View Full Code Here

   * @see org.objectweb.joram.shared.stream.Streamable#writeTo(java.io.OutputStream)
   */
  public void writeTo(OutputStream os) throws IOException {
    StreamUtil.writeTo(principal, os);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    try {
      oos.writeObject(subject);
      oos.flush();
      StreamUtil.writeTo(baos.toByteArray(), os);
      oos.close();
      baos.close();
    } finally {
      try {
        oos.close();
      } catch (IOException exc) {}
      try {
        baos.close();
      } catch (IOException exc) {}
    }
View Full Code Here

        ClobType cv = new ClobType(clob);
        String key = cv.getReferenceStreamId();
       
        // now force to serialize
        File saved = new File(UnitTestUtil.getTestScratchPath()+"/clobassaved.bin"); //$NON-NLS-1$
        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(saved));
        out.writeObject(cv);
        out.close();
       
        // now read back the object from serilized state
        ObjectInputStream in = new ObjectInputStream(new FileInputStream(saved));
        ClobType read = (ClobType)in.readObject();
       
View Full Code Here

      return filePath;
  }
 
  public static final <T extends Serializable> T helpSerialize(T object) throws IOException, ClassNotFoundException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(object);
        oos.flush();
       
        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
       
        return (T)ois.readObject();
  }
View Full Code Here

        super(name);
    }

    public void setUp() throws Exception {
        bout = new ByteArrayOutputStream(4096);
        oout = new ObjectOutputStream(bout);
    }
View Full Code Here

       
        Object result = randomSymCryptor.sealObject(test);

        //ensure that we can serialize
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(result);
       
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        ObjectInputStream ois = new ObjectInputStream(bais);
        result = ois.readObject();
       
View Full Code Here

    public static <T> T deepCopy(final Object orig) {
        final Object obj;
        try {
            // write the object
            final FastMultiByteArrayOutputStream fbos = new FastMultiByteArrayOutputStream();
            final ObjectOutputStream out = new ObjectOutputStream(fbos);
            out.writeObject(orig);
            out.flush();
            out.close();
            // read an object
            final ObjectInputStream in = new ObjectInputStream(fbos.getInputStream());
            obj = in.readObject();
        } catch (IOException e) {
            throw new IllegalStateException(e);
View Full Code Here

        return bos.toByteArray_clear();
    }

    public static void toStream(final Object obj, final OutputStream out) {
        try {
            final ObjectOutputStream oos = new ObjectOutputStream(out);
            oos.writeObject(obj);
            oos.flush();
            oos.close();
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
    }
View Full Code Here

TOP

Related Classes of java.io.ObjectOutputStream$PutField

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.