Package java.io

Examples of java.io.ObjectOutputStream.writeObject()


  @Override
  public Object javaToSqlArg(FieldType fieldType, Object obj) throws SQLException {
    try {
      ByteArrayOutputStream outStream = new ByteArrayOutputStream();
      ObjectOutputStream objOutStream = new ObjectOutputStream(outStream);
      objOutStream.writeObject(obj);
      return outStream.toByteArray();
    } catch (Exception e) {
      throw SqlExceptionUtil.create("Could not write serialized object to byte array: " + obj, e);
    }
  }
View Full Code Here


    public static byte[] serialize(Serializable obj) {
        ObjectOutputStream oos = null;
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            oos = new ObjectOutputStream(baos);
            oos.writeObject(obj);
            return baos.toByteArray();
        } catch (NotSerializableException e) {
            throw new IllegalStateException(e.getMessage());
        } catch (IOException e) {
            throw new IllegalStateException(e.getMessage());
View Full Code Here

  public void testSerialize() throws Exception
  {
    final Band e = new Band();
    final ByteArrayOutputStream bo = new ByteArrayOutputStream();
    final ObjectOutputStream out = new ObjectOutputStream(bo);
    out.writeObject(e);

    final ObjectInputStream oin = new ObjectInputStream(new ByteArrayInputStream(bo.toByteArray()));
    final Element e2 = (Element) oin.readObject();
    assertNotNull(e2); // cannot assert equals, as this is not implemented.
  }
View Full Code Here

  {
    final CustomPageDefinition cpd = new CustomPageDefinition();

    final ByteArrayOutputStream bo = new ByteArrayOutputStream();
    final ObjectOutputStream out = new ObjectOutputStream(bo);
    out.writeObject(cpd);
    out.close();

    final ObjectInputStream oin = new ObjectInputStream
      (new ByteArrayInputStream(bo.toByteArray()));
    final Object e2 = oin.readObject();
View Full Code Here

    cpd.addPageFormat(new PageFormat(), 400, 0);
    cpd.addPageFormat(new PageFormat(), 400, 400);

    final ByteArrayOutputStream bo = new ByteArrayOutputStream();
    final ObjectOutputStream out = new ObjectOutputStream(bo);
    out.writeObject(cpd);
    out.close();

    final ObjectInputStream oin = new ObjectInputStream
      (new ByteArrayInputStream(bo.toByteArray()));
    final Object e2 = oin.readObject();
View Full Code Here

  public void testSerialize() throws Exception
  {
    final Element e = new Element();
    final ByteArrayOutputStream bo = new ByteArrayOutputStream();
    final ObjectOutputStream out = new ObjectOutputStream(bo);
    out.writeObject(e);

    final ObjectInputStream oin = new ObjectInputStream(new ByteArrayInputStream(bo.toByteArray()));
    final Element e2 = (Element) oin.readObject();
    assertNotNull(e2); // cannot assert equals, as this is not implemented ...
  }
View Full Code Here

  public void testSerialize() throws Exception
  {
    final MasterReport report = new MasterReport();
    final ByteArrayOutputStream bo = new ByteArrayOutputStream();
    final ObjectOutputStream out = new ObjectOutputStream(bo);
    out.writeObject(report);

    final ObjectInputStream oin = new ObjectInputStream(new ByteArrayInputStream(bo.toByteArray()));
    final MasterReport e2 = (MasterReport) oin.readObject();
    assertNotNull(e2); // cannot assert equals, as this is not implemented.
  }
View Full Code Here

   * @see it.unimi.dsi.mg4j.document.DocumentCollectionBuilder#nonTextField(java.lang.Object)
   */
  public void nonTextField( final Object o ) throws IOException {
    if ( DEBUG ) LOGGER.debug( "Going to write non-text field " + o + " of class " + o.getClass() + " for document #" + numberOfDocuments );
    ObjectOutputStream oos = new ObjectOutputStream( zipOut );
    oos.writeObject( o );
    oos.flush();
  }
 
  /* (non-Javadoc)
   * @see it.unimi.dsi.mg4j.document.DocumentCollectionBuilder#virtualField(it.unimi.dsi.fastutil.objects.ObjectList)
View Full Code Here

     */
    public static byte[] serialize(Object obj) {
        try {
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            ObjectOutputStream os = new ObjectOutputStream(out);
            os.writeObject(obj);
            return out.toByteArray();
        } catch (Throwable e) {
            throw DbException.get(ErrorCode.SERIALIZATION_FAILED_1, e, e.toString());
        }
    }
View Full Code Here

        final ObjectOutputStream oos;
        try {
            oos = new ObjectOutputStream(os);
            oos.writeInt(actsize);
            for(int i = 0; i < actsize; i++) {
                oos.writeObject(result[i]);
                result[i] = null;
            }
            oos.flush();
        } catch (IOException e) {
            throw new RemoteException("failed to serialize", e);
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.