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

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

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

ObjectInputStream.readInt介绍

[英]Reads an integer (32 bit) from the source stream.
[中]从源流中读取一个整数(32位)。

代码示例

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

/**
 * Populates a multiset by reading an input stream, as part of deserialization. See {@link
 * #writeMultiset} for the data format. The number of distinct elements is determined by a prior
 * call to {@link #readCount}.
 */
static <E> void populateMultiset(
  Multiset<E> multiset, ObjectInputStream stream, int distinctElements)
  throws IOException, ClassNotFoundException {
 for (int i = 0; i < distinctElements; i++) {
  @SuppressWarnings("unchecked") // reading data stored by writeMultiset
  E element = (E) stream.readObject();
  int count = stream.readInt();
  multiset.add(element, count);
 }
}

代码示例来源:origin: hankcs/HanLP

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
  size = in.readInt();
  data = (int[]) in.readObject();
  linearExpandFactor = in.readInt();
  exponentialExpanding = in.readBoolean();
  exponentialExpandFactor = in.readDouble();
}

代码示例来源: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: ch.qos.logback/logback-classic

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
  in.defaultReadObject();
  int levelInt = in.readInt();
  level = Level.toLevel(levelInt);
  int argArrayLen = in.readInt();
  if (argArrayLen != NULL_ARGUMENT_ARRAY) {
    argumentArray = new String[argArrayLen];
    for (int i = 0; i < argArrayLen; i++) {
      Object val = in.readObject();
      if (!NULL_ARGUMENT_ARRAY_ELEMENT.equals(val)) {
        argumentArray[i] = val;
      }
    }
  }
}

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

protected void readBaseObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
  serverName = (String)in.readObject();
  databaseName = (String)in.readObject();
  user = (String)in.readObject();
  password = (String)in.readObject();
  portNumber = in.readInt();
  prepareThreshold = in.readInt();
  unknownLength = in.readInt();
  loginTimeout = in.readInt();
  socketTimeout = in.readInt();
  ssl = in.readBoolean();
  sslfactory = (String)in.readObject();
  tcpKeepAlive = in.readBoolean();
  compatible = (String)in.readObject();
  logLevel = in.readInt();
  protocolVersion = in.readInt();
  applicationName = (String)in.readObject();
}

代码示例来源:origin: cc.mallet/mallet

private void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException
{
 in.defaultReadObject ();
 in.readInt (); // serial version
 var = (Variable) in.readObject ();
 alpha = in.readDouble ();
 beta = in.readDouble ();
 min = in.readDouble ();
 max = in.readDouble ();
}

代码示例来源:origin: frohoff/ysoserial

ois.readInt(); // method
ois.readLong(); // hash
System.err.println("Is DGC call for " + Arrays.toString((ObjID[])ois.readObject()));

代码示例来源:origin: dcm4che/dcm4che-core

private void readObject(ObjectInputStream s) throws IOException,
ClassNotFoundException {
  s.defaultReadObject();
  tag = s.readInt();
  vr = VR.valueOf(s.readUnsignedShort());
  bigEndian = s.readBoolean();
  int n = s.readInt();
  items = new ArrayList<Object>(n);
  for (int i = 0; i < n; ++i) {
    items.add(s.readObject());
  }
}

代码示例来源:origin: io.snappydata/gemfire-trove

private void readObject(ObjectInputStream stream)
  throws IOException, ClassNotFoundException {
  stream.defaultReadObject();
  int size = stream.readInt();
  setUp(size);
  while (size-- > 0) {
    Object key = stream.readObject();
    long val = stream.readLong();
    put(key, val);
  }
}

代码示例来源:origin: aa112901/remusic

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    String name = (String) in.readObject();
    String value = (String) in.readObject();
    clientCookie = new HttpCookie(name, value);
    clientCookie.setComment((String) in.readObject());
    clientCookie.setCommentURL((String) in.readObject());
    clientCookie.setDomain((String) in.readObject());
    clientCookie.setMaxAge(in.readLong());
    clientCookie.setPath((String) in.readObject());
    clientCookie.setPortlist((String) in.readObject());
    clientCookie.setVersion(in.readInt());
    clientCookie.setSecure(in.readBoolean());
    clientCookie.setDiscard(in.readBoolean());
  }
}

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

/** Reconstitutes the instance from a stream (that is, deserializes it). */
 private void readObject(java.io.ObjectInputStream s)
   throws java.io.IOException, ClassNotFoundException {
  s.defaultReadObject();

  // Read in array length and allocate array
  int length = s.readInt();
  this.longs = new AtomicLongArray(length);

  // Read in all elements in the proper order.
  for (int i = 0; i < length; i++) {
   set(i, s.readDouble());
  }
 }
}

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

private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
    // read the non-transient fields
    in.defaultReadObject();

    // read the default value field
    boolean hasDefaultValue = in.readBoolean();
    if (hasDefaultValue) {
      int size = in.readInt();

      byte[] buffer = new byte[size];

      in.readFully(buffer);

      try (ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
          DataInputViewStreamWrapper inView = new DataInputViewStreamWrapper(bais)) {

        defaultValue = serializer.deserialize(inView);
      }
      catch (Exception e) {
        throw new IOException("Unable to deserialize default value.", e);
      }
    } else {
      defaultValue = null;
    }
  }
}

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

private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException {
  featureCount = input.readInt();
  userCount = input.readInt();
  itemCount = input.readInt();
  RealMatrix umat = MatrixUtils.createRealMatrix(userCount, featureCount);
  for (int i = 0; i < userCount; i++) {
    for (int j = 0; j < featureCount; j++) {
      umat.setEntry(i, j, input.readDouble());
    }
  }
  userMatrix = umat;
  RealMatrix imat = MatrixUtils.createRealMatrix(itemCount, featureCount);
  for (int i = 0; i < itemCount; i++) {
    for (int j = 0; j < featureCount; j++) {
      imat.setEntry(i, j, input.readDouble());
    }
  }
  itemMatrix = imat;
  userIndex = (KeyIndex) input.readObject();
  itemIndex = (KeyIndex) input.readObject();
  if (userIndex.size() != userMatrix.getRowDimension()) {
    throw new InvalidObjectException("user matrix and index have different row counts");
  }
  if (itemIndex.size() != itemMatrix.getRowDimension()) {
    throw new InvalidObjectException("item matrix and index have different row counts");
  }
}

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

nextBytes = new byte[DIGEST_LENGTH];
seedLength = ois.readLong();
counter = ois.readLong();
state = ois.readInt();
seed[BYTES_OFFSET] = ois.readInt();
    seed[i] = ois.readInt();
    seed[HASH_OFFSET + i] = ois.readInt();
    seed[FRAME_LENGTH] = ois.readInt();
    seed[FRAME_LENGTH + 1] = ois.readInt();
    seed[FRAME_LENGTH + 14] = ois.readInt();
    seed[FRAME_LENGTH + 15] = ois.readInt();
    seed[i] = ois.readInt();
    copies[FRAME_LENGTH + EXTRAFRAME_OFFSET + i] = ois.readInt();
    copies[i] = ois.readInt();
    seed[HASH_OFFSET + i] = ois.readInt();
nextBIndex = ois.readInt();
Streams.readFully(ois, nextBytes, nextBIndex, HASHBYTES_TO_USE - nextBIndex);

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

private void readObject(final ObjectInputStream o)
    throws IOException, ClassNotFoundException {
  final long lowestDiscernibleValue = o.readLong();
  final long highestTrackableValue = o.readLong();
  final int numberOfSignificantValueDigits = o.readInt();
  final int normalizingIndexOffset = o.readInt();
  final double integerToDoubleValueConversionRatio = o.readDouble();
  final long indicatedTotalCount = o.readLong();
  final long indicatedMaxValue = o.readLong();
  final long indicatedMinNonZeroValue = o.readLong();
  final long indicatedStartTimeStampMsec = o.readLong();
  final long indicatedEndTimeStampMsec = o.readLong();
  final boolean indicatedAutoResize = o.readBoolean();
  final int indicatedwordSizeInBytes = o.readInt();
  init(lowestDiscernibleValue, highestTrackableValue, numberOfSignificantValueDigits,
      integerToDoubleValueConversionRatio, normalizingIndexOffset);
  // Set internalTrackingValues (can't establish them from array yet, because it's not yet read...)
  setTotalCount(indicatedTotalCount);
  maxValue = indicatedMaxValue;
  minNonZeroValue = indicatedMinNonZeroValue;
  startTimeStampMsec = indicatedStartTimeStampMsec;
  endTimeStampMsec = indicatedEndTimeStampMsec;
  autoResize = indicatedAutoResize;
  wordSizeInBytes = indicatedwordSizeInBytes;
}

代码示例来源:origin: oracle/opengrok

private void readObject(ObjectInputStream in) throws ClassNotFoundException,
    IOException {
  boolean hasValue = in.readBoolean();
  String vstring = in.readUTF();
  projectName = hasValue ? vstring : null;
  hasValue = in.readBoolean();
  int vint = in.readInt();
  tabSize = hasValue ? vint : null;
  hasValue = in.readBoolean();
  long vlong = in.readLong();
  analyzerGuruVersion = hasValue ? vlong : null;
  /**
   * De-serialization circumvents normal construction, so the following
   * field could be null.
   */
  if (analyzersVersions == null) {
    analyzersVersions = new HashMap<>();
  }
  int analyzerCount = in.readInt();
  for (int i = 0; i < analyzerCount; ++i) {
    vstring = in.readUTF();
    vlong = in.readLong();
    analyzersVersions.put(vstring, vlong);
  }
}

代码示例来源:origin: org.apache.commons/commons-math3

final int n = ois.readInt();
final int m = ois.readInt();
final double[][] data = new double[n][m];
for (int i = 0; i < n; ++i) {
  final double[] dataI = data[i];
  for (int j = 0; j < m; ++j) {
    dataI[j] = ois.readDouble();

代码示例来源: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: commons-beanutils/commons-beanutils

if (in.readBoolean()) {
  switch (in.readInt()) {
  return ((Class<?>) in.readObject());

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

/**
 * Populates a multimap by reading an input stream, as part of deserialization. See {@link
 * #writeMultimap} for the data format. The number of distinct keys is determined by a prior call
 * to {@link #readCount}.
 */
static <K, V> void populateMultimap(
  Multimap<K, V> multimap, ObjectInputStream stream, int distinctKeys)
  throws IOException, ClassNotFoundException {
 for (int i = 0; i < distinctKeys; i++) {
  @SuppressWarnings("unchecked") // reading data stored by writeMultimap
  K key = (K) stream.readObject();
  Collection<V> values = multimap.get(key);
  int valueCount = stream.readInt();
  for (int j = 0; j < valueCount; j++) {
   @SuppressWarnings("unchecked") // reading data stored by writeMultimap
   V value = (V) stream.readObject();
   values.add(value);
  }
 }
}

相关文章

ObjectInputStream类方法