本文整理匯總了Java中java.io.ObjectOutput.writeObject方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectOutput.writeObject方法的具體用法?Java ObjectOutput.writeObject怎麽用?Java ObjectOutput.writeObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.io.ObjectOutput
的用法示例。
在下文中一共展示了ObjectOutput.writeObject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testSerialization
import java.io.ObjectOutput; //導入方法依賴的package包/類
/**
* 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);
}
示例2: writeExternal
import java.io.ObjectOutput; //導入方法依賴的package包/類
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]);
}
}
}
示例3: testSerialization
import java.io.ObjectOutput; //導入方法依賴的package包/類
/**
* 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
}
示例4: writeExternal
import java.io.ObjectOutput; //導入方法依賴的package包/類
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// LIST
out.writeObject( list );
}
示例5: generaArrayDati
import java.io.ObjectOutput; //導入方法依賴的package包/類
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;
}
示例6: writeExternal
import java.io.ObjectOutput; //導入方法依賴的package包/類
@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();
}
示例7: writeExternal
import java.io.ObjectOutput; //導入方法依賴的package包/類
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte( 0 );
// LIST
out.writeObject( _list );
}
示例8: writeExternal
import java.io.ObjectOutput; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(setFunc);
out.writeObject(getFunc);
out.writeInt(rows);
out.writeInt(cols);
}
示例9: writeExternal
import java.io.ObjectOutput; //導入方法依賴的package包/類
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);
}
示例10: writeExternal
import java.io.ObjectOutput; //導入方法依賴的package包/類
/**
* 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);
}
示例11: writeExternal
import java.io.ObjectOutput; //導入方法依賴的package包/類
@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);
}
示例12: writeExternal
import java.io.ObjectOutput; //導入方法依賴的package包/類
/**
* 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);
}
示例13: writeExternal
import java.io.ObjectOutput; //導入方法依賴的package包/類
@Override
public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal(out);
out.writeObject(iGroup);
out.writeInt(iLimit);
}
示例14: writeExternal
import java.io.ObjectOutput; //導入方法依賴的package包/類
public void writeExternal(ObjectOutput out) throws IOException {
out.writeInt(_bitSize);
out.writeInt(_mask);
out.writeObject(_bits);
out.flush();
}
示例15: writeExternal
import java.io.ObjectOutput; //導入方法依賴的package包/類
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeUTF(this.mark);
out.writeObject(this.target);
}