java.io.ObjectOutputStream.defaultWriteObject()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(308)

本文整理了Java中java.io.ObjectOutputStream.defaultWriteObject()方法的一些代码示例,展示了ObjectOutputStream.defaultWriteObject()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectOutputStream.defaultWriteObject()方法的具体详情如下:
包路径:java.io.ObjectOutputStream
类名称:ObjectOutputStream
方法名:defaultWriteObject

ObjectOutputStream.defaultWriteObject介绍

[英]Default method to write objects to this stream. Serializable fields defined in the object's class and superclasses are written to the output stream.
[中]将对象写入此流的默认方法。对象类和超类中定义的可序列化字段被写入输出流。

代码示例

代码示例来源:origin: google/guava

/** @serialData the ConcurrentMap of elements and their counts. */
private void writeObject(ObjectOutputStream stream) throws IOException {
 stream.defaultWriteObject();
 stream.writeObject(countMap);
}

代码示例来源:origin: google/guava

/**
 * The serial form currently mimics Android's java.util.HashSet version, e.g. see
 * http://omapzoom.org/?p=platform/libcore.git;a=blob;f=luni/src/main/java/java/util/HashSet.java
 */
private void writeObject(ObjectOutputStream stream) throws IOException {
 stream.defaultWriteObject();
 stream.writeInt(size);
 for (E e : this) {
  stream.writeObject(e);
 }
}

代码示例来源:origin: google/j2objc

/**
 * The serial form currently mimics Android's java.util.HashMap version, e.g. see
 * http://omapzoom.org/?p=platform/libcore.git;a=blob;f=luni/src/main/java/java/util/HashMap.java
 */
private void writeObject(ObjectOutputStream stream) throws IOException {
 stream.defaultWriteObject();
 stream.writeInt(size);
 for (int i = 0; i < size; i++) {
  stream.writeObject(keys[i]);
  stream.writeObject(values[i]);
 }
}

代码示例来源:origin: google/guava

/**
 * @serialData the key class, number of entries, first key, first value, second key, second value,
 *     and so on.
 */
@GwtIncompatible // java.io.ObjectOutputStream
private void writeObject(ObjectOutputStream stream) throws IOException {
 stream.defaultWriteObject();
 stream.writeObject(keyType);
 Serialization.writeMap(this, stream);
}

代码示例来源:origin: h2oai/h2o-2

private void writeObject(java.io.ObjectOutputStream s) throws IOException  {
 s.defaultWriteObject();     // Write nothing
 for( long K : keySet() ) {
  final Object V = get(K);  // Do an official 'get'
  s.writeLong  (K);         // Write the <long,TypeV> pair
  s.writeObject(V);
 }
 s.writeLong(NO_KEY);        // Sentinel to indicate end-of-data
 s.writeObject(null);
}

代码示例来源:origin: google/guava

/**
 * @serialData the number of distinct keys, and then for each distinct key: the first key, the
 *     number of values for that key, and the key's values, followed by successive keys and values
 *     from the entries() ordering
 */
@GwtIncompatible // java.io.ObjectOutputStream
private void writeObject(ObjectOutputStream stream) throws IOException {
 stream.defaultWriteObject();
 stream.writeInt(size());
 for (Entry<K, V> entry : entries()) {
  stream.writeObject(entry.getKey());
  stream.writeObject(entry.getValue());
 }
}

代码示例来源:origin: google/guava

private void writeObject(ObjectOutputStream s) throws IOException {
 s.defaultWriteObject();
 s.writeLong(sum());
}

代码示例来源:origin: google/guava

/**
 * Saves the state to a stream (that is, serializes it).
 *
 * @serialData The length of the array is emitted (int), followed by all of its elements (each a
 *     {@code double}) in the proper order.
 */
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
 s.defaultWriteObject();
 // Write out array length
 int length = length();
 s.writeInt(length);
 // Write out all elements in the proper order.
 for (int i = 0; i < length; i++) {
  s.writeDouble(get(i));
 }
}

代码示例来源:origin: google/guava

/**
 * Saves the state to a stream (that is, serializes it).
 *
 * @serialData The current value is emitted (a {@code double}).
 */
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
 s.defaultWriteObject();
 s.writeDouble(get());
}

代码示例来源:origin: google/guava

/**
 * The serial form currently mimics Android's java.util.HashMap version, e.g. see
 * http://omapzoom.org/?p=platform/libcore.git;a=blob;f=luni/src/main/java/java/util/HashMap.java
 */
private void writeObject(ObjectOutputStream stream) throws IOException {
 stream.defaultWriteObject();
 stream.writeInt(size);
 for (int i = 0; i < size; i++) {
  stream.writeObject(keys[i]);
  stream.writeObject(values[i]);
 }
}

代码示例来源:origin: google/guava

/** @serialData the forward bimap */
@GwtIncompatible // java.io.ObjectOutputStream
private void writeObject(ObjectOutputStream stream) throws IOException {
 stream.defaultWriteObject();
 stream.writeObject(inverse());
}

代码示例来源:origin: prestodb/presto

/** @serialData the ConcurrentMap of elements and their counts. */
private void writeObject(ObjectOutputStream stream) throws IOException {
 stream.defaultWriteObject();
 stream.writeObject(countMap);
}

代码示例来源:origin: JCTools/JCTools

private void writeObject(java.io.ObjectOutputStream s) throws IOException  {
 s.defaultWriteObject();     // Write nothing
 for( long K : keySet() ) {
  final Object V = get(K);  // Do an official 'get'
  s.writeLong  (K);         // Write the <long,TypeV> pair
  s.writeObject(V);
 }
 s.writeLong(NO_KEY);        // Sentinel to indicate end-of-data
 s.writeObject(null);
}

代码示例来源:origin: google/j2objc

/**
 * @serialData the number of distinct keys, and then for each distinct key: the first key, the
 *     number of values for that key, and the key's values, followed by successive keys and values
 *     from the entries() ordering
 */
@GwtIncompatible // java.io.ObjectOutputStream
private void writeObject(ObjectOutputStream stream) throws IOException {
 stream.defaultWriteObject();
 stream.writeInt(size());
 for (Entry<K, V> entry : entries()) {
  stream.writeObject(entry.getKey());
  stream.writeObject(entry.getValue());
 }
}

代码示例来源:origin: google/guava

private void writeObject(ObjectOutputStream s) throws IOException {
 s.defaultWriteObject();
 s.writeLong(sum());
}

代码示例来源:origin: log4j/log4j

/**
 * Serialize level.
 * @param s serialization stream.
 * @throws IOException if exception during serialization.
 */
private void writeObject(final ObjectOutputStream s) throws IOException {
  s.defaultWriteObject();
  s.writeInt(level);
  s.writeInt(syslogEquivalent);
  s.writeUTF(levelStr);
}

代码示例来源:origin: prestodb/presto

/**
 * Saves the state to a stream (that is, serializes it).
 *
 * @serialData The length of the array is emitted (int), followed by all of its elements (each a
 *     {@code double}) in the proper order.
 */
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
 s.defaultWriteObject();
 // Write out array length
 int length = length();
 s.writeInt(length);
 // Write out all elements in the proper order.
 for (int i = 0; i < length; i++) {
  s.writeDouble(get(i));
 }
}

代码示例来源:origin: prestodb/presto

/**
 * Saves the state to a stream (that is, serializes it).
 *
 * @serialData The current value is emitted (a {@code double}).
 */
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
 s.defaultWriteObject();
 s.writeDouble(get());
}

代码示例来源:origin: prestodb/presto

/**
 * The serial form currently mimics Android's java.util.HashSet version, e.g. see
 * http://omapzoom.org/?p=platform/libcore.git;a=blob;f=luni/src/main/java/java/util/HashSet.java
 */
private void writeObject(ObjectOutputStream stream) throws IOException {
 stream.defaultWriteObject();
 stream.writeInt(size);
 for (E e : this) {
  stream.writeObject(e);
 }
}

代码示例来源:origin: google/guava

/** @serialData the factory and the backing map */
@GwtIncompatible // java.io.ObjectOutputStream
private void writeObject(ObjectOutputStream stream) throws IOException {
 stream.defaultWriteObject();
 stream.writeObject(factory);
 stream.writeObject(backingMap());
}

相关文章

ObjectOutputStream类方法