java.io.ObjectInputStream.defaultReadObject()方法的使用及代码示例

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

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

ObjectInputStream.defaultReadObject介绍

[英]Default method to read objects from this stream. Serializable fields defined in the object's class and superclasses are read from the source stream.
[中]从该流读取对象的默认方法。从源流中读取对象类和超类中定义的可序列化字段。

代码示例

代码示例来源:origin: apache/flink

private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
  stream.defaultReadObject();
  value = (T) stream.readObject();
}

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

@GwtIncompatible // java.io.ObjectInputStream
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
 stream.defaultReadObject();
 keyToKeyList = Maps.newLinkedHashMap();
 int size = stream.readInt();
 for (int i = 0; i < size; i++) {
  @SuppressWarnings("unchecked") // reading data stored by writeObject
  K key = (K) stream.readObject();
  @SuppressWarnings("unchecked") // reading data stored by writeObject
  V value = (V) stream.readObject();
  put(key, value);
 }
}

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

@GwtIncompatible // java.io.ObjectInputStream
@SuppressWarnings("unchecked") // reading data stored by writeObject
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
 stream.defaultReadObject();
 factory = (Supplier<? extends List<V>>) stream.readObject();
 Map<K, Collection<V>> map = (Map<K, Collection<V>>) stream.readObject();
 setMap(map);
}

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

@SuppressWarnings("unchecked")
 private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
  stream.defaultReadObject();
  init(DEFAULT_SIZE, DEFAULT_LOAD_FACTOR);
  int elementCount = stream.readInt();
  for (int i = elementCount; --i >= 0; ) {
   K key = (K) stream.readObject();
   V value = (V) stream.readObject();
   put(key, value);
  }
 }
}

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

/**
 * Custom deserialization of Level.
 * @param s serialization stream.
 * @throws IOException if IO exception.
 * @throws ClassNotFoundException if class not found.
 */
private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException {
 s.defaultReadObject();
 level = s.readInt();
 syslogEquivalent = s.readInt();
 levelStr = s.readUTF();
 if (levelStr == null) {
   levelStr = "";
 }
}

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

@SuppressWarnings("unchecked")
 private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
  stream.defaultReadObject();
  init(DEFAULT_SIZE, DEFAULT_LOAD_FACTOR);
  int elementCount = stream.readInt();
  for (int i = elementCount; --i >= 0; ) {
   E element = (E) stream.readObject();
   add(element);
  }
 }
}

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

@GwtIncompatible // java.io.ObjectInputStream
@SuppressWarnings("unchecked") // reading data stored by writeObject
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
 stream.defaultReadObject();
 factory = (Supplier<? extends SortedSet<V>>) stream.readObject();
 valueComparator = factory.get().comparator();
 Map<K, Collection<V>> map = (Map<K, Collection<V>>) stream.readObject();
 setMap(map);
}

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

private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
 stream.defaultReadObject();
 @SuppressWarnings("unchecked") // reading data stored by writeObject
 ConcurrentMap<E, Integer> deserializedCountMap =
   (ConcurrentMap<E, Integer>) stream.readObject();
 FieldSettersHolder.COUNT_MAP_FIELD_SETTER.set(this, deserializedCountMap);
}

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

@GwtIncompatible // java.io.ObjectInputStream
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
 stream.defaultReadObject();
 keyToKeyList = CompactLinkedHashMap.create();
 int size = stream.readInt();
 for (int i = 0; i < size; i++) {
  @SuppressWarnings("unchecked") // reading data stored by writeObject
  K key = (K) stream.readObject();
  @SuppressWarnings("unchecked") // reading data stored by writeObject
  V value = (V) stream.readObject();
  put(key, value);
 }
}

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

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    this.hashCode = in.readInt();
  }
}

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

private synchronized void readObject(ObjectInputStream in)
      throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    Object[] snapshot = new Object[in.readInt()];
    for (int i = 0; i < snapshot.length; i++) {
      snapshot[i] = in.readObject();
    }
    elements = snapshot;
  }
}

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

@GwtIncompatible // java.io.ObjectInputStream
@SuppressWarnings("unchecked") // reading data stored by writeObject
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
 stream.defaultReadObject();
 setInverse((AbstractBiMap<V, K>) stream.readObject());
}

代码示例来源:origin: jeasonlzy/okhttp-OkGo

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    String mediaTypeString = (String) in.readObject();
    if (!TextUtils.isEmpty(mediaTypeString)) {
      mediaType = MediaType.parse(mediaTypeString);
    }
  }
}

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

@GwtIncompatible // java.io.ObjectInputStream
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
 stream.defaultReadObject();
 int keyCount = stream.readInt();
 if (keyCount < 0) {
  throw new InvalidObjectException("Invalid key count " + keyCount);
  Object key = stream.readObject();
  int valueCount = stream.readInt();
  if (valueCount <= 0) {
   throw new InvalidObjectException("Invalid value count " + valueCount);
   valuesBuilder.add(stream.readObject());

代码示例来源:origin: apache/flink

private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException {
  in.defaultReadObject();
  int numKeyFields = in.readInt();
  keyFields = new Field[numKeyFields];
  for (int i = 0; i < numKeyFields; i++) {
    keyFields[i] = FieldSerializer.deserializeField(in);
  }
}

代码示例来源:origin: commons-collections/commons-collections

/**
 * Read the buffer in using a custom routine.
 * 
 * @param in  the input stream
 * @throws IOException
 * @throws ClassNotFoundException
 */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
  in.defaultReadObject();
  int size = in.readInt();
  buffer = new Object[size + 1];
  for (int i = 0; i < size; i++) {
    buffer[i] = in.readObject();
  }
  head = 0;
  tail = size;
}

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

@GwtIncompatible // java.io.ObjectInputStream
@SuppressWarnings("unchecked") // reading data stored by writeObject
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
 stream.defaultReadObject();
 factory = (Supplier<? extends Set<V>>) stream.readObject();
 Map<K, Collection<V>> map = (Map<K, Collection<V>>) stream.readObject();
 setMap(map);
}

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

private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
 stream.defaultReadObject();
 @SuppressWarnings("unchecked") // reading data stored by writeObject
 ConcurrentMap<E, Integer> deserializedCountMap =
   (ConcurrentMap<E, Integer>) stream.readObject();
 FieldSettersHolder.COUNT_MAP_FIELD_SETTER.set(this, deserializedCountMap);
}

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

@GwtIncompatible // java.io.ObjectInputStream
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
 stream.defaultReadObject();
 keyToKeyList = Maps.newLinkedHashMap();
 int size = stream.readInt();
 for (int i = 0; i < size; i++) {
  @SuppressWarnings("unchecked") // reading data stored by writeObject
  K key = (K) stream.readObject();
  @SuppressWarnings("unchecked") // reading data stored by writeObject
  V value = (V) stream.readObject();
  put(key, value);
 }
}

代码示例来源:origin: org.apache.logging.log4j/log4j-api

private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
  in.defaultReadObject();
  formattedMessage = in.readUTF();
  messagePattern = in.readUTF();
  final int length = in.readInt();
  stringArgs = new String[length];
  for (int i = 0; i < length; ++i) {
    stringArgs[i] = in.readUTF();
  }
}

相关文章

ObjectInputStream类方法