當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectOutput.writeObject方法代碼示例

本文整理匯總了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);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:23,代碼來源:VectorDataItemTests.java

示例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]);
        }
    }
}
 
開發者ID:JianpingZeng,項目名稱:xcc,代碼行數:19,代碼來源:THashMap.java

示例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
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:27,代碼來源:DialValueIndicatorTests.java

示例4: writeExternal

import java.io.ObjectOutput; //導入方法依賴的package包/類
public void writeExternal( ObjectOutput out ) throws IOException {
    // VERSION
    out.writeByte(0);

    // LIST
    out.writeObject( list );
}
 
開發者ID:JianpingZeng,項目名稱:xcc,代碼行數:8,代碼來源:TCharListDecorator.java

示例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;
}
 
開發者ID:ilofX,項目名稱:StazioneMetereologica,代碼行數:14,代碼來源:DataManager.java

示例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();
}
 
開發者ID:enoy19,項目名稱:keyboard-light-composer,代碼行數:9,代碼來源:KlcColor.java

示例7: writeExternal

import java.io.ObjectOutput; //導入方法依賴的package包/類
public void writeExternal( ObjectOutput out ) throws IOException {
	// VERSION
	out.writeByte( 0 );

	// LIST
	out.writeObject( _list );
}
 
開發者ID:JianpingZeng,項目名稱:xcc,代碼行數:8,代碼來源:TIntArrayStack.java

示例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);
}
 
開發者ID:Luodian,項目名稱:Higher-Cloud-Computing-Project,代碼行數:8,代碼來源:FunctionMatrixStorage.java

示例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);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:8,代碼來源:ValueExpressionImpl.java

示例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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:DataFlavor.java

示例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);
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:10,代碼來源:RpcMessage.java

示例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);
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:14,代碼來源:FacesMessageWrapper.java

示例13: writeExternal

import java.io.ObjectOutput; //導入方法依賴的package包/類
@Override
public void writeExternal(ObjectOutput out) throws IOException {
	super.writeExternal(out);
	out.writeObject(iGroup);
	out.writeInt(iLimit);
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:7,代碼來源:XGroupReservation.java

示例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();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:7,代碼來源:BitArray.java

示例15: writeExternal

import java.io.ObjectOutput; //導入方法依賴的package包/類
@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeUTF(this.mark);
    out.writeObject(this.target);
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:6,代碼來源:JspMethodExpression.java


注:本文中的java.io.ObjectOutput.writeObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。