Example usage for java.io ObjectOutput writeObject

List of usage examples for java.io ObjectOutput writeObject

Introduction

In this page you can find the example usage for java.io ObjectOutput writeObject.

Prototype

public void writeObject(Object obj) throws IOException;

Source Link

Document

Write an object to the underlying storage or stream.

Usage

From source file:org.jfree.data.time.junit.MinuteTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *//*from   w ww  . j  a  v  a2s. c o  m*/
public void testSerialization() {
    Minute m1 = new Minute();
    Minute m2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(m1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        m2 = (Minute) in.readObject();
        in.close();
    } catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(m1, m2);
}

From source file:com.sherdle.universal.ConfigParser.java

public void saveJSONToCache(String json) {
    // Instantiate a JSON object from the request response
    try {/*from   www .ja v a2 s  .  com*/
        // Save the JSONObject
        ObjectOutput out = null;

        out = new ObjectOutputStream(new FileOutputStream(new File(context.getCacheDir(), "") + CACHE_FILE));

        out.writeObject(json);
        out.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:org.jfree.data.time.junit.MillisecondTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 */// ww w  . j a v  a2s.  c o  m
public void testSerialization() {
    Millisecond m1 = new Millisecond();
    Millisecond m2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(m1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        m2 = (Millisecond) in.readObject();
        in.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(m1, m2);
}

From source file:com.conwet.silbops.model.ContextFunction.java

@Override
public void writeExternal(ObjectOutput output) throws IOException {

    output.writeInt(constraint.size());/* w  w  w .j  a v a 2 s.c  o m*/

    for (Entry<Key, Value> entry : constraint.entrySet()) {

        output.writeObject(entry.getKey());
        valueExt.writeExternal(output, entry.getValue());
    }
}

From source file:edu.wustl.cab2b.admin.flex.DAGNode.java

/**
 * It serializes DAGNode for communication with flex client
 * /*w  ww.j  a  va 2  s .  c  o m*/
 * @param out
 * @throws IOException
 */

public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(nodeName);
    out.writeUTF(toolTip);
    out.writeInt((int) nodeId);
    out.writeUTF(operatorBetweenAttrAndAssociation);
    out.writeUTF(nodeType);
    out.writeObject(associationList);
    out.writeObject(operatorList);
    out.writeObject(dagpathList);
    out.writeUTF(errorMsg);
    out.writeInt(xCordinate);
    out.writeInt(yCordinate);
    out.writeInt((int) entityId);
    out.writeObject(attributesList);
}

From source file:org.photovault.replication.ValueChange.java

public void writeExternal(ObjectOutput out) throws IOException {
    out.writeObject(name);
    out.writeObject(getValue());
}

From source file:com.splicemachine.derby.stream.function.RowAndIndexGenerator.java

@Override
public void writeExternal(ObjectOutput out) throws IOException {
    try {/*  www .jav  a2  s .  c  o  m*/
        out.writeLong(heapConglom);
        out.writeBoolean(operationContext != null);
        if (operationContext != null)
            out.writeObject(operationContext);
        SIDriver.driver().getOperationFactory().writeTxn(txn, out);
        ArrayUtil.writeIntArray(out, pkCols);
        out.writeUTF(tableVersion);
        out.writeObject(execRowDefinition);
        out.writeInt(autoIncrementRowLocationArray.length);
        for (int i = 0; i < autoIncrementRowLocationArray.length; i++)
            out.writeObject(autoIncrementRowLocationArray[i]);
        out.writeInt(spliceSequences.length);
        for (int i = 0; i < spliceSequences.length; i++) {
            out.writeObject(spliceSequences[i]);
        }
        out.writeLong(heapConglom);
        out.writeInt(tentativeIndices.size());
        for (DDLMessage.TentativeIndex ti : tentativeIndices) {
            byte[] message = ti.toByteArray();
            out.writeInt(message.length);
            out.write(message);
        }
    } catch (Exception e) {
        throw new IOException(e);
    }

}

From source file:com.almende.eve.state.file.ConcurrentSerializableFileState.java

/**
 * write properties to disk./*from  w w w . j  ava 2s .  co  m*/
 * 
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
private void write() throws IOException {
    if (channel != null) {
        channel.position(0);
    }
    final ObjectOutput out = new ObjectOutputStream(fos);
    out.writeObject(properties);
    out.flush();

    if (channel != null) {
        channel.truncate(channel.position());
    }
}

From source file:LinkedList.java

public void writeExternal(ObjectOutput out) throws IOException {
    out.writeObject(firstNode);
    out.writeObject(lastNode);/*  w w w.j a  va 2 s.co m*/
    out.writeInt(size);
    out.writeObject(iterator);
}

From source file:org.jfree.data.time.junit.HourTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *//* w w w.  jav a2  s. co m*/
public void testSerialization() {
    Hour h1 = new Hour();
    Hour h2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(h1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        h2 = (Hour) in.readObject();
        in.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(h1, h2);
}