Package java.io

Examples of java.io.ObjectOutputStream


            throw new IllegalStateException(e.getMessage());
        }
    }

    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());
        } finally {
            if (oos != null) {
                try {
                    oos.close();
                } catch (IOException e) {
                    throw new IllegalStateException(
                        "Failed to close stream to DiskCache, "
                        + "cache may be corrupted. Reason: " + e.getMessage());
                }
View Full Code Here


   *          underlying output stream this object is bound to
   * @throws IOException
   *           any IO errors during transmittion
   */
  public PacketOutputStream(OutputStream out) throws IOException {
    this.out = new ObjectOutputStream(out);

  }
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

          throws IOException, ClassNotFoundException
  {
    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();
    assertNotNull(e2); // cannot assert equals, as this is not implemented.
View Full Code Here

    cpd.addPageFormat(new PageFormat(), 0, 400);
    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();
    assertNotNull(e2); // cannot assert equals, as this is not implemented.
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

  /* (non-Javadoc)
   * @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();
  }
View Full Code Here

     * @return the byte array
     */
    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

        }
    }

    private static XQEventDecoder pipedIn(ObjectInput in, boolean reaccessable) throws IOException {
        final FastMultiByteArrayOutputStream bufOut = new FastMultiByteArrayOutputStream(BUFFERING_BLOCK_SIZE);
        final ObjectOutputStream objectOut = new ObjectOutputStream(bufOut);
        final XQEventDecoder decoder = new XQEventDecoder(in);
        decoder.redirectTo(objectOut);
        objectOut.flush();

        final byte[][] buf = bufOut.toMultiByteArray();
        final int totalBufSize = bufOut.size();
        bufOut.clear();
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.