Examples of ObjectInputStream


Examples of java.io.ObjectInputStream

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

        FastByteArrayInputStream bis3 = new FastByteArrayInputStream(b2);
        ObjectInputStream ois3 = new ObjectInputStream(bis3);
        Assert.assertEquals(student2, ois3.readObject());
        Assert.assertEquals(student3, ois3.readObject());

        out.close();

        final byte[] b = f.toByteArray();
        FastByteArrayInputStream in = new FastByteArrayInputStream(b);
        ObjectInputStream oin = new ObjectInputStream(in);

        Assert.assertEquals(student1, oin.readObject());
        Assert.assertEquals(5, oin.readInt());

        int size3 = oin.readInt();
        byte[] b3 = new byte[size3];
        oin.read(b3);
        ArrayAssert.assertEquals(b2, b3);

        FastByteArrayInputStream bis4 = new FastByteArrayInputStream(b3);
        ObjectInputStream ois4 = new ObjectInputStream(bis4);
        Assert.assertEquals(student2, ois4.readObject());
        Assert.assertEquals(student3, ois4.readObject());

        oin.close();
    }
View Full Code Here

Examples of java.io.ObjectInputStream

        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 java.io.ObjectInputStream

            byte[] b = new byte[size];
            s.readFully(b, 0, size);
            this.ser23 = b;

            FastByteArrayInputStream bis3 = new FastByteArrayInputStream(b);
            ObjectInputStream ois3 = new ObjectInputStream(bis3);
            this.student2 = (Student) ois3.readObject();
            this.student3 = (Student) ois3.readObject();
        }
View Full Code Here

Examples of java.io.ObjectInputStream

        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();
        assertEquals(list1, list2);
    }
View Full Code Here

Examples of java.io.ObjectInputStream

   * @see org.objectweb.joram.shared.stream.Streamable#readFrom(java.io.InputStream)
   */
  public void readFrom(InputStream is) throws IOException {
    principal = StreamUtil.readStringFrom(is);
    ByteArrayInputStream bais = null;
    ObjectInputStream ois = null;
    try {
      byte[] subByte = StreamUtil.readByteArrayFrom(is);
      bais = new ByteArrayInputStream(subByte);
      ois = new ObjectInputStream(bais);
      try {
        subject = (Subject) ois.readObject();
      } catch (ClassNotFoundException e) {
        if (logger.isLoggable(BasicLevel.ERROR))
          logger.log(BasicLevel.ERROR, "EXCEPTION:: readFrom", e);
        throw new IOException(e.getMessage());
      }
    } finally {
      try {
        ois.close();
      } catch (IOException exc) {}
      try {
        bais.close();
      } catch (IOException exc) {}
    }
View Full Code Here

Examples of java.io.ObjectInputStream

  }


  private ObjectInputStream getObjectInputStream(File f) throws IOException {
    return new ObjectInputStream(new BufferedInputStream(new FileInputStream(f), 0x4000));
  }
View Full Code Here

Examples of java.io.ObjectInputStream

        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();
       
        assertTrue(read.length() > 0);
               
        // make sure we have kept the reference stream id
        assertEquals(key, read.getReferenceStreamId());
View Full Code Here

Examples of java.io.ObjectInputStream

    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

Examples of java.io.ObjectInputStream

   
    public void testEmptyCollection() throws Exception {
      ExternalizeUtil.writeCollection(oout, Arrays.asList(new Object[0]));
      oout.flush();       
        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
        ObjectInputStream oin = new ObjectInputStream(bin);
       
        List<?> result = ExternalizeUtil.readList(oin);
        assertEquals(0, result.size());
    }
View Full Code Here

Examples of java.io.ObjectInputStream

        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(saved));
        out.writeObject(bv);
        out.close();
       
        // now read back the object from serilized state
        ObjectInputStream in = new ObjectInputStream(new FileInputStream(saved));
        BlobType read = (BlobType)in.readObject();
               
        // make sure we have kept the reference stream id
        assertEquals(key, read.getReferenceStreamId());
       
        // and lost the original object
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.