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

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

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

ObjectOutputStream.writeInt介绍

[英]Writes an integer (32 bit) to the target stream.
[中]将整数(32位)写入目标流。

代码示例

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

void writeMapTo(ObjectOutputStream out) throws IOException {
 out.writeInt(delegate.size());
 for (Entry<K, V> entry : delegate.entrySet()) {
  out.writeObject(entry.getKey());
  out.writeObject(entry.getValue());
 }
 out.writeObject(null); // terminate entries
}

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

/**
 * Write the map out using a custom routine.
 * @param out  the output stream
 * @throws IOException
 */
protected void doWriteObject(ObjectOutputStream out) throws IOException {
  out.writeInt(map.size());
  for (Iterator it = map.entrySet().iterator(); it.hasNext();) {
    Map.Entry entry = (Map.Entry) it.next();
    out.writeObject(entry.getKey());
    out.writeInt(((MutableInteger) entry.getValue()).value);
  }
}

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

private void writeObject(ObjectOutputStream out) throws IOException
{
  loseWeight();
  out.writeInt(size);
  out.writeObject(data);
  out.writeInt(linearExpandFactor);
  out.writeBoolean(exponentialExpanding);
  out.writeDouble(exponentialExpandFactor);
}

代码示例来源:origin: com.github.romix/java-concurrent-hash-trie-map

private void writeObject(ObjectOutputStream outputStream) throws IOException {
    outputStream.defaultWriteObject();

    final Map<K, V> ro = readOnlySnapshot();
    outputStream.writeBoolean(isReadOnly());
    outputStream.writeInt(ro.size());

    for (Entry<K, V> e : ro.entrySet()) {
      outputStream.writeObject(e.getKey());
      outputStream.writeObject(e.getValue());
    }
  }
}

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

private void writeObject(java.io.ObjectOutputStream s) throws IOException  {
 s.defaultWriteObject();     // Nothing to write
 final NBSI nbsi = _nbsi;    // The One Field is transient
 final int len = _nbsi._bits.length<<6;
 s.writeInt(len);            // Write max element
 for( int i=0; i<len; i++ ) 
  s.writeBoolean( _nbsi.contains(i) );
}

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

private void writeObject(ObjectOutputStream out) throws IOException {
    out.writeBoolean(projectName != null); // hasValue
    out.writeUTF(projectName == null ? "" : projectName);

    out.writeBoolean(tabSize != null); // hasValue
    out.writeInt(tabSize == null ? 0 : tabSize);

    out.writeBoolean(analyzerGuruVersion != null); // hasValue
    out.writeLong(analyzerGuruVersion == null ? 0 : analyzerGuruVersion);

    int analyzerCount = analyzersVersions.size();
    out.writeInt(analyzerCount);
    for (Map.Entry<String, Long> entry : analyzersVersions.entrySet()) {
      out.writeUTF(entry.getKey());
      out.writeLong(entry.getValue());
      --analyzerCount;
    }
    if (analyzerCount != 0) {
      throw new IllegalStateException("analyzersVersions were modified");
    }
  }
}

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

/**
 * Write the map out using a custom routine.
 * @param out  the output stream
 * @throws IOException
 */
protected void doWriteObject(ObjectOutputStream out) throws IOException {
  out.writeInt(map.size());
  for (Iterator it = map.entrySet().iterator(); it.hasNext();) {
    Map.Entry entry = (Map.Entry) it.next();
    out.writeObject(entry.getKey());
    out.writeInt(((MutableInteger) entry.getValue()).value);
  }
}

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

/**
 * Stores the contents of a map in an output stream, as part of serialization. It does not support
 * concurrent maps whose content may change while the method is running.
 *
 * <p>The serialized output consists of the number of entries, first key, first value, second key,
 * second value, and so on.
 */
static <K, V> void writeMap(Map<K, V> map, ObjectOutputStream stream) throws IOException {
 stream.writeInt(map.size());
 for (Map.Entry<K, V> entry : map.entrySet()) {
  stream.writeObject(entry.getKey());
  stream.writeObject(entry.getValue());
 }
}

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

protected void writeBaseObject(ObjectOutputStream out) throws IOException
{
  out.writeObject(serverName);
  out.writeObject(databaseName);
  out.writeObject(user);
  out.writeObject(password);
  out.writeInt(portNumber);
  out.writeInt(prepareThreshold);
  out.writeInt(unknownLength);
  out.writeInt(loginTimeout);
  out.writeInt(socketTimeout);
  out.writeBoolean(ssl);
  out.writeObject(sslfactory);
  out.writeBoolean(tcpKeepAlive);
  out.writeObject(compatible);
  out.writeInt(logLevel);
  out.writeInt(protocolVersion);
  out.writeObject(applicationName);
}

代码示例来源:origin: romix/java-concurrent-hash-trie-map

private void writeObject(ObjectOutputStream outputStream) throws IOException {
    outputStream.defaultWriteObject();

    final Map<K, V> ro = readOnlySnapshot();
    outputStream.writeBoolean(isReadOnly());
    outputStream.writeInt(ro.size());

    for (Entry<K, V> e : ro.entrySet()) {
      outputStream.writeObject(e.getKey());
      outputStream.writeObject(e.getValue());
    }
  }
}

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

private void writeObject(java.io.ObjectOutputStream s) throws IOException  {
 s.defaultWriteObject();     // Nothing to write
 final NBSI nbsi = _nbsi;    // The One Field is transient
 final int len = _nbsi._bits.length<<6;
 s.writeInt(len);            // Write max element
 for( int i=0; i<len; i++ ) 
  s.writeBoolean( _nbsi.contains(i) );
}

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

private void writeObject(final ObjectOutputStream o)
    throws IOException
{
  o.writeLong(lowestDiscernibleValue);
  o.writeLong(highestTrackableValue);
  o.writeInt(numberOfSignificantValueDigits);
  o.writeInt(getNormalizingIndexOffset());
  o.writeDouble(integerToDoubleValueConversionRatio);
  o.writeLong(getTotalCount());
  // Max Value is added to the serialized form because establishing max via scanning is "harder" during
  // deserialization, as the counts array is not available at the subclass deserializing level, and we don't
  // really want to have each subclass establish max on it's own...
  o.writeLong(maxValue);
  o.writeLong(minNonZeroValue);
  o.writeLong(startTimeStampMsec);
  o.writeLong(endTimeStampMsec);
  o.writeBoolean(autoResize);
  o.writeInt(wordSizeInBytes);
}

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

private void writeObject(ObjectOutputStream stream) throws IOException {
  stream.defaultWriteObject();
  stream.writeInt(mappingsCount);
  Iterator<Map.Entry<K, V>> iterator = entrySet().iterator();
  while (iterator.hasNext()) {
    Map.Entry<K, V> entry = iterator.next();
    stream.writeObject(entry.getKey());
    stream.writeObject(entry.getValue());
  }
}

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

private void writeObject(ObjectOutputStream out) throws IOException
{
  out.writeInt(size);
  out.writeObject(base);
  out.writeObject(check);
}

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

out.writeBoolean(false);
  out.writeObject(clazz);
} else {
  out.writeBoolean(true);
  out.writeInt(primitiveType);

相关文章

ObjectOutputStream类方法