java.io.ObjectOutput#writeObject ( )源码实例Demo

下面列出了java.io.ObjectOutput#writeObject ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: astor   文件: MonthDateFormatTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    MonthDateFormat mf1 = new MonthDateFormat();
    MonthDateFormat mf2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(mf1);
        out.close();

        ObjectInput in = new ObjectInputStream(
            new ByteArrayInputStream(buffer.toByteArray())
        );
        mf2 = (MonthDateFormat) in.readObject();
        in.close();
    }
    catch (Exception e) {
        fail(e.toString());
    }
    assertTrue(mf1.equals(mf2));
}
 
源代码2 项目: astor   文件: PowerFunction2DTests.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    PowerFunction2D f1 = new PowerFunction2D(1.0, 2.0);
    PowerFunction2D f2 = null;

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

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
                buffer.toByteArray()));
        f2 = (PowerFunction2D) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(f1, f2);
}
 
源代码3 项目: ignite   文件: VisorRestConfiguration.java
/** {@inheritDoc} */
@Override protected void writeExternalData(ObjectOutput out) throws IOException {
    out.writeBoolean(restEnabled);
    out.writeBoolean(tcpSslEnabled);
    U.writeString(out, jettyPath);
    U.writeString(out, jettyHost);
    out.writeObject(jettyPort);
    U.writeString(out, tcpHost);
    out.writeInt(tcpPort);
    U.writeString(out, tcpSslCtxFactory);
    U.writeString(out, secretKey);
    out.writeBoolean(noDelay);
    out.writeBoolean(directBuf);
    out.writeInt(sndBufSize);
    out.writeInt(rcvBufSize);
    out.writeLong(idleQryCurTimeout);
    out.writeLong(idleQryCurCheckFreq);
    out.writeInt(sndQueueLimit);
    out.writeInt(selectorCnt);
    out.writeLong(idleTimeout);
    out.writeBoolean(sslClientAuth);
    U.writeString(out, sslFactory);
    out.writeInt(portRange);
    U.writeString(out, msgInterceptor);
}
 
源代码4 项目: protect   文件: CertifiedDecision.java
public void writeExternal(ObjectOutput out) throws IOException {

		out.writeInt(pid);
		out.writeInt(cid);
		out.writeObject(decision);
		out.writeObject(consMsgs);
	}
 
源代码5 项目: jdk8u_jdk   文件: TCPEndpoint.java
/**
 * Write endpoint to output stream.
 */
public void write(ObjectOutput out) throws IOException {
    if (csf == null) {
        out.writeByte(FORMAT_HOST_PORT);
        out.writeUTF(host);
        out.writeInt(port);
    } else {
        out.writeByte(FORMAT_HOST_PORT_FACTORY);
        out.writeUTF(host);
        out.writeInt(port);
        out.writeObject(csf);
    }
}
 
源代码6 项目: ignite   文件: PlatformJavaObjectFactoryProxy.java
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(factoryTyp);
    U.writeString(out, clsName);
    out.writeObject(payload);
    U.writeMap(out, props);
}
 
@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));
}
 
源代码8 项目: triplea   文件: DiceRoll.java
@Override
public void writeExternal(final ObjectOutput out) throws IOException {
  final int[] dice = new int[rolls.size()];
  for (int i = 0; i < rolls.size(); i++) {
    dice[i] = rolls.get(i).getCompressedValue();
  }
  out.writeObject(dice);
  out.writeInt(hits);
  out.writeDouble(expectedHits);
}
 
源代码9 项目: spliceengine   文件: ExplainOperation.java
@Override
public void writeExternal(ObjectOutput out) throws IOException {
    super.writeExternal(out);
    out.writeInt(explainString.size());
    for (int i = 0; i < explainString.size(); ++i) {
        out.writeUTF(explainString.get(i));
    }
    out.writeUTF(sparkExplainKind.toString());
    if (!sparkExplainKind.equals(ExplainNode.SparkExplainKind.NONE))
        out.writeObject(source);
}
 
源代码10 项目: TencentKona-8   文件: ActivatableRef.java
/**
 * Write out external representation for remote ref.
 */
public void writeExternal(ObjectOutput out) throws IOException
{
    RemoteRef localRef = ref;

    out.writeObject(id);
    if (localRef == null) {
        out.writeUTF("");
    } else {
        out.writeUTF(localRef.getRefClass(out));
        localRef.writeExternal(out);
    }
}
 
源代码11 项目: astor   文件: FirstOrderIntegratorWithJacobians.java
/** {@inheritDoc} */
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeObject(interpolator);
    out.writeInt(y.length);
    out.writeInt(dydp[0].length);
    writeArray(out, y);
    writeArray(out, dydy0);
    writeArray(out, dydp);
    writeArray(out, yDot);
    writeArray(out, dydy0Dot);
    writeArray(out, dydpDot);
}
 
源代码12 项目: butterfly   文件: UserPhases.java
@Override
public void writeExternal(ObjectOutput out) throws IOException {
    out.writeLong(this.id);
    out.writeObject(this.user);
    out.writeInt(this.ddr16Phase);
}
 
源代码13 项目: astor   文件: AbstractStepInterpolator.java
/** Save the base state of the instance.
 * This method performs step finalization if it has not been done
 * before.
 * @param out stream where to save the state
 * @exception IOException in case of write error
 */
protected void writeBaseExternal(final ObjectOutput out)
  throws IOException {

  if (currentState == null) {
      out.writeInt(-1);
  } else {
      out.writeInt(currentState.length);
  }
  out.writeDouble(globalPreviousTime);
  out.writeDouble(globalCurrentTime);
  out.writeDouble(softPreviousTime);
  out.writeDouble(softCurrentTime);
  out.writeDouble(h);
  out.writeBoolean(forward);
  out.writeObject(primaryMapper);
  out.write(secondaryMappers.length);
  for (final EquationsMapper  mapper : secondaryMappers) {
      out.writeObject(mapper);
  }

  if (currentState != null) {
      for (int i = 0; i < currentState.length; ++i) {
          out.writeDouble(currentState[i]);
      }
  }

  out.writeDouble(interpolatedTime);

  // we do not store the interpolated state,
  // it will be recomputed as needed after reading

  try {
      // finalize the step (and don't bother saving the now true flag)
      finalizeStep();
  } catch (MaxCountExceededException mcee) {
      final IOException ioe = new IOException(mcee.getLocalizedMessage());
      ioe.initCause(mcee);
      throw ioe;
  }

}
 
源代码14 项目: gemfirexd-oss   文件: PbcastHeader.java
public void writeExternal(ObjectOutput out) throws IOException {
out.writeInt(type);
out.writeLong(seqno);
out.writeObject(gossip);
out.writeObject(xmit_reqs);
   }
 
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
    out.writeObject(filter);
}
 
源代码16 项目: reladomo   文件: TimestampLessThanOperation.java
public void writeExternal(ObjectOutput out) throws IOException
{
    out.writeObject(this.getAttribute());
    TimestampAttribute timestampAttribute = (TimestampAttribute) this.getAttribute();
    timestampAttribute.writeToStream(out, (Timestamp)this.getParameter());
}
 
源代码17 项目: spliceengine   文件: TableScannerBuilder.java
@Override
public void writeExternal(ObjectOutput out) throws IOException{
        out.writeObject(template);
        writeScan(out);
        out.writeBoolean(rowColumnMap!=null);
        if(rowColumnMap!=null){
            out.writeInt(rowColumnMap.length);
            //noinspection ForLoopReplaceableByForEach
            for(int i=0;i<rowColumnMap.length;++i){
                out.writeInt(rowColumnMap[i]);
            }
        }
        writeTxn(out);
        ArrayUtil.writeByteArray(out, token);
        ArrayUtil.writeIntArray(out,keyColumnEncodingOrder);
        ArrayUtil.writeIntArray(out,partitionByColumns);

        out.writeBoolean(keyColumnSortOrder!=null);
        if(keyColumnSortOrder!=null){
            ArrayUtil.writeBooleanArray(out,keyColumnSortOrder);
        }
        ArrayUtil.writeIntArray(out,keyColumnTypes);
        out.writeBoolean(keyDecodingMap!=null);
        if(keyDecodingMap!=null){
            ArrayUtil.writeIntArray(out,keyDecodingMap);
        }
        out.writeBoolean(baseColumnMap!=null);
        if(baseColumnMap!=null){
            ArrayUtil.writeIntArray(out,baseColumnMap);
        }
        out.writeObject(accessedKeys);
        out.writeBoolean(reuseRowLocation);
        out.writeBoolean(oneSplitPerRegion);
        out.writeBoolean(indexName!=null);
        if(indexName!=null)
            out.writeUTF(indexName);
        out.writeBoolean(tableVersion!=null);
        if(tableVersion!=null)
            out.writeUTF(tableVersion);

        out.writeBoolean(fieldLengths!=null);
        if(fieldLengths!=null){
            out.writeInt(fieldLengths.length);
            //noinspection ForLoopReplaceableByForEach
            for(int i=0;i<fieldLengths.length;++i){
                out.writeInt(fieldLengths[i]);
            }
            out.writeInt(columnPositionMap.length);
            //noinspection ForLoopReplaceableByForEach
            for(int i=0;i<columnPositionMap.length;++i){
                out.writeInt(columnPositionMap[i]);
            }
            out.writeLong(baseTableConglomId);
        }
        out.writeLong(demarcationPoint);
        out.writeBoolean(optionalProbeValue !=null);
        if (optionalProbeValue!=null)
            out.writeObject(optionalProbeValue);
        out.writeBoolean(pin);
        writeNullableString(delimited,out);
        writeNullableString(escaped,out);
        writeNullableString(lines,out);
        writeNullableString(storedAs,out);
        writeNullableString(location,out);
        out.writeBoolean(useSample);
        out.writeDouble(sampleFraction);
        out.writeBoolean(defaultRow != null);
        if (defaultRow != null)
            out.writeObject(defaultRow);
        out.writeBoolean(defaultValueMap != null);
        if (defaultValueMap != null)
            out.writeObject(defaultValueMap);
        out.writeBoolean(ignoreRecentTransactions);
}
 
源代码18 项目: symja_android_library   文件: ASTRealVector.java
@Override
public void writeExternal(ObjectOutput objectOutput) throws IOException {
	objectOutput.writeShort(fEvalFlags);
	objectOutput.writeObject(vector);
}
 
源代码19 项目: reladomo   文件: NonPrimitiveNotInOperation.java
protected void writeParameter(ObjectOutput out, Object o) throws IOException
{
    out.writeObject(o);
}
 
源代码20 项目: activemq-artemis   文件: JNDIStorable.java
/**
 * Method for class's implementing externalizable to delegate to if not custom implementing.
 *
 * @param out
 * @throws IOException
 * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
 */
public void writeObject(ObjectOutput out) throws IOException {
   out.writeObject(getProperties());
}