本文整理汇总了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);
}