Java Code Examples for java.io.ObjectOutput.writeObject()

The following are Jave code examples for showing how to use writeObject() of the java.io.ObjectOutput class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: parabuild-ci   File: VectorDataItemTests.java   Source Code and License Vote up 6 votes
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    VectorDataItem v1 = new VectorDataItem(1.0, 2.0, 3.0, 4.0);
    VectorDataItem v2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(v1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        v2 = (VectorDataItem) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(v1, v2);
}
 
Example 2
Project: xcc   File: THashMap.java   Source Code and License Vote up 6 votes
public void writeExternal(ObjectOutput out) throws IOException {
    // VERSION
    out.writeByte(1);

    // NOTE: Super was not written in version 0
    super.writeExternal(out);

    // NUMBER OF ENTRIES
    out.writeInt(_size);

    // ENTRIES
    for (int i = _set.length; i-- > 0;) {
        if (_set[i] != REMOVED && _set[i] != FREE) {
            out.writeObject(_set[i]);
            out.writeObject(_values[i]);
        }
    }
}
 
Example 3
Project: parabuild-ci   File: DialValueIndicatorTests.java   Source Code and License Vote up 6 votes
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    // test a default instance
    DialValueIndicator i1 = new DialValueIndicator(0, "Label");
    DialValueIndicator i2 = null;

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

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        i2 = (DialValueIndicator) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(i1, i2);
    
    // test a custom instance
}
 
Example 4
Project: xcc   File: TCharListDecorator.java   Source Code and License Vote up 5 votes
public void writeExternal( ObjectOutput out ) throws IOException {
    // VERSION
    out.writeByte(0);

    // LIST
    out.writeObject( list );
}
 
Example 5
Project: StazioneMetereologica   File: DataManager.java   Source Code and License Vote up 5 votes
public byte[] generaArrayDati(){
    try {
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        ObjectOutput outObject = new ObjectOutputStream(outStream);
        synchronized (this.data){
            outObject.writeObject(this.data);
        }
        return outStream.toByteArray();
    } catch (IOException ex) {
        Logger.getLogger(DataManager.class.getName()).log(Level.SEVERE, null, ex);
    }
return null;
}
 
Example 6
Project: keyboard-light-composer   File: KlcColor.java   Source Code and License Vote up 5 votes
@Override
public void writeExternal(ObjectOutput out) throws IOException {
	out.writeObject(color.getRed());
	out.writeObject(color.getGreen());
	out.writeObject(color.getBlue());
	out.writeObject(color.getOpacity());
	out.flush();
}
 
Example 7
Project: xcc   File: TIntArrayStack.java   Source Code and License Vote up 5 votes
public void writeExternal( ObjectOutput out ) throws IOException {
	// VERSION
	out.writeByte( 0 );

	// LIST
	out.writeObject( _list );
}
 
Example 8
Project: Higher-Cloud-Computing-Project   File: FunctionMatrixStorage.java   Source Code and License Vote up 5 votes
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
    out.writeObject(setFunc);
    out.writeObject(getFunc);
    out.writeInt(rows);
    out.writeInt(cols);
}
 
Example 9
Project: HCFCore   File: TFloatListDecorator.java   Source Code and License Vote up 5 votes
public void writeExternal( ObjectOutput out ) throws IOException {
    // VERSION
    out.writeByte(0);

    // LIST
    out.writeObject( list );
}
 
Example 10
Project: lams   File: ValueExpressionImpl.java   Source Code and License Vote up 5 votes
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(this.expr);
    out.writeUTF((this.expectedType != null) ? this.expectedType.getName()
            : "");
    out.writeObject(this.fnMapper);
    out.writeObject(this.varMapper);
}
 
Example 11
Project: openjdk-jdk10   File: DataFlavor.java   Source Code and License Vote up 5 votes
/**
  * Serializes this {@code DataFlavor}.
  */
public synchronized void writeExternal(ObjectOutput os) throws IOException {
    if (mimeType != null) {
        mimeType.setParameter("humanPresentableName", humanPresentableName);
        os.writeObject(mimeType);
        mimeType.removeParameter("humanPresentableName");
    } else {
        os.writeObject(null);
    }

    os.writeObject(representationClass);
}
 
Example 12
Project: tomcat7   File: RpcMessage.java   Source Code and License Vote up 5 votes
@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeBoolean(reply);
    out.writeInt(uuid.length);
    out.write(uuid, 0, uuid.length);
    out.writeInt(rpcId.length);
    out.write(rpcId, 0, rpcId.length);
    out.writeObject(message);
}
 
Example 13
Project: HCFCore   File: TFloatArrayStack.java   Source Code and License Vote up 5 votes
public void writeExternal( ObjectOutput out ) throws IOException {
	// VERSION
	out.writeByte( 0 );

	// LIST
	out.writeObject( _list );
}
 
Example 14
Project: myfaces-trinidad   File: FacesMessageWrapper.java   Source Code and License Vote up 5 votes
/**
 * Writes this object to the serialized stream.
 * 
 * @param objectOutput
 * @throws IOException
 */
public void writeExternal(ObjectOutput objectOutput)
  throws IOException
{
  objectOutput.writeLong(serialVersionUID);
  objectOutput.writeObject(_wrapped);
  objectOutput.writeObject(_label);
}
 
Example 15
Project: unitimes   File: XGroupReservation.java   Source Code and License Vote up 4 votes
@Override
public void writeExternal(ObjectOutput out) throws IOException {
	super.writeExternal(out);
	out.writeObject(iGroup);
	out.writeInt(iLimit);
}
 
Example 16
Project: OpenJSharp   File: BitArray.java   Source Code and License Vote up 4 votes
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(_bitSize);
    out.writeInt(_mask);
    out.writeObject(_bits);
    out.flush();
}
 
Example 17
Project: apache-tomcat-7.0.73-with-comment   File: JspMethodExpression.java   Source Code and License Vote up 4 votes
@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(this.mark);
    out.writeObject(this.target);
}
 
Example 18
Project: lazycat   File: JspValueExpression.java   Source Code and License Vote up 4 votes
@Override
public void writeExternal(ObjectOutput out) throws IOException {
	out.writeUTF(this.mark);
	out.writeObject(this.target);
}
 
Example 19
Project: lazycat   File: MethodExpressionLiteral.java   Source Code and License Vote up 4 votes
@Override
public void writeExternal(ObjectOutput out) throws IOException {
	out.writeUTF(this.expr);
	out.writeUTF((this.expectedType != null) ? this.expectedType.getName() : "");
	out.writeObject(ReflectionUtil.toTypeNameArray(this.paramTypes));
}
 
Example 20
Project: Higher-Cloud-Computing-Project   File: SparseLocalOnHeapVectorStorage.java   Source Code and License Vote up 4 votes
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(size);
    out.writeInt(acsMode);
    out.writeObject(sto);
}