當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectInputStream.readInt方法代碼示例

本文整理匯總了Java中java.io.ObjectInputStream.readInt方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectInputStream.readInt方法的具體用法?Java ObjectInputStream.readInt怎麽用?Java ObjectInputStream.readInt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.ObjectInputStream的用法示例。


在下文中一共展示了ObjectInputStream.readInt方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doReps

import java.io.ObjectInputStream; //導入方法依賴的package包/類
/**
 * Run benchmark for given number of batches, with given number of cycles
 * for each batch.
 */
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
            StreamBuffer sbuf, int nbatches, int ncycles)
    throws Exception
{
    for (int i = 0; i < nbatches; i++) {
        sbuf.reset();
        for (int j = 0; j < ncycles; j++) {
            oout.writeInt(0);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readInt();
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:20,代碼來源:Ints.java

示例2: populateMultimap

import java.io.ObjectInputStream; //導入方法依賴的package包/類
/**
 * 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);
    }
  }
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:21,代碼來源:Serialization.java

示例3: readObject

import java.io.ObjectInputStream; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
/** Custom serialization */
private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException {
    this.coding = (IntCoding<T>)is.readObject();
    final int length = is.readInt();
    this.codes = new int[length];
    for (int i=0; i<length; ++i) {
        codes[i] = is.readInt();
    }
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:11,代碼來源:DenseArrayWithIntCoding.java

示例4: deserializeMainFile

import java.io.ObjectInputStream; //導入方法依賴的package包/類
@Override
public void deserializeMainFile(ObjectInputStream objectInputStream) throws IOException,
    ClassNotFoundException {
    highestPermanentVertexId = objectInputStream.readInt();
    highestMergedVertexId = highestPermanentVertexId;
    int forwardAdjListsLength = objectInputStream.readInt();
    int backwardAdjListsLength = objectInputStream.readInt();
    forwardAdjLists = new SortedAdjacencyList[forwardAdjListsLength];
    backwardAdjLists = new SortedAdjacencyList[backwardAdjListsLength];
    initializeSortedAdjacencyLists(0, highestPermanentVertexId + 1);
    vertexTypes.deserialize(objectInputStream);
}
 
開發者ID:graphflow,項目名稱:graphflow,代碼行數:13,代碼來源:Graph.java

示例5: readObject

import java.io.ObjectInputStream; //導入方法依賴的package包/類
/**
 * Loads (deserializes) this node's content from the source stream.
 * 
 * @param in
 *            source stream
 * 
 * @throws IOException
 *             any I/O exception
 * @throws ClassNotFoundException
 *             class not found
 */
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
	in.defaultReadObject();
	byte[] bytes = new byte[in.readInt()];
	in.readFully(bytes);
	try {
		value = JavaBuiltin.deserialize(bytes);
	} catch (Exception e) {
		throw new IOException(e);
	}
	moveMeta();
}
 
開發者ID:berkesa,項目名稱:datatree,代碼行數:23,代碼來源:Tree.java

示例6: readMapMaker

import java.io.ObjectInputStream; //導入方法依賴的package包/類
@SuppressWarnings("deprecation") // serialization of deprecated feature
MapMaker readMapMaker(ObjectInputStream in) throws IOException {
  int size = in.readInt();
  return new MapMaker()
      .initialCapacity(size)
      .setKeyStrength(keyStrength)
      .setValueStrength(valueStrength)
      .keyEquivalence(keyEquivalence)
      .concurrencyLevel(concurrencyLevel);
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:11,代碼來源:MapMakerInternalMap.java

示例7: readObject

import java.io.ObjectInputStream; //導入方法依賴的package包/類
protected void readObject(ObjectInputStream in) throws IOException {
	loaded = in.readBoolean();
	
	ArrayList<Point3D> allVertices = Lists.newArrayList();
	int vertexCount = in.readInt();
	while ( allVertices.size() < vertexCount ) {
		double x = in.readDouble();
		double y = in.readDouble();
		double z = in.readDouble(); 
		allVertices.add( new Point3D( x, y, z ) );
	}
	
	triangles = Lists.newArrayList();
	int triangleCount = in.readInt();
	while ( triangles.size() < triangleCount ) {
		Point3D triangleVertices[] = new Point3D[3];
		for ( int i=0; i<3; ++i ) {
    		triangleVertices[i] = allVertices.get( in.readInt() );
		}
		triangles.add( new Triangle( triangleVertices[0], triangleVertices[1], triangleVertices[2] ) );
	}
	
    bspTree = BspTree.make( new RayCastBspStrategy( this, new Random(250760834l) ) );
    rayCaster = new RayCaster( bspTree );
    
    bspTree.setRoot( readNode( in ) );
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:28,代碼來源:LevelGeometry.java

示例8: readObject

import java.io.ObjectInputStream; //導入方法依賴的package包/類
void readObject(ObjectInputStream in) throws IOException {
    long t = in.readLong();
    time = new Date(t);
    int len = in.readInt();
    newNames = new String[len];
    for (int i = 0; i < len; i++) {
        newNames[i] = in.readUTF();
    }
    len = in.readInt();
    newids = new int[len];
    for (int i = 0; i < len; i++) {
        newids[i] = in.readInt();
    }
    len = in.readInt();
    ids = new int[len];
    for (int i = 0; i < len; i++) {
        ids[i] = in.readInt();
    }
    len = in.readInt();
    instances = new long[len];
    for (int i = 0; i < len; i++) {
        instances[i] = in.readLong();
    }
    len = in.readInt();
    bytes = new long[len];
    for (int i = 0; i < len; i++) {
        bytes[i] = in.readLong();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:30,代碼來源:HeapHistogramResponse.java

示例9: populateMultiset

import java.io.ObjectInputStream; //導入方法依賴的package包/類
/**
 * 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);
  }
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:16,代碼來源:Serialization.java

示例10: readObject

import java.io.ObjectInputStream; //導入方法依賴的package包/類
private void readObject(ObjectInputStream s) throws IOException,
		ClassNotFoundException{
	s.defaultReadObject();
	int numElements = s.readInt();
	
	//Read in all elements and insert them in list
	for (int i = 0; i < numElements; i++) {
		add((String) s.readObject());
	}
}
 
開發者ID:turoDog,項目名稱:effectiveJava,代碼行數:11,代碼來源:StringList.java

示例11: readObject

import java.io.ObjectInputStream; //導入方法依賴的package包/類
private void readObject(ObjectInputStream s) throws IOException,
		ClassNotFoundException {
	s.defaultReadObject();
	
	// Manually deserialize and initialize superclass state
	//�ֶ������л��ͳ�ʼ������״̬
	int x = s.readInt();
	int y = s.readInt();
	initialize(x, y);
}
 
開發者ID:turoDog,項目名稱:effectiveJava,代碼行數:11,代碼來源:Foo.java

示例12: read

import java.io.ObjectInputStream; //導入方法依賴的package包/類
@Override
public final void read(ObjectInputStream is, int count) throws IOException {
    for (int i=0; i<count; ++i) {
        final int value = is.readInt();
        this.codes.put(i, value);
    }
}
 
開發者ID:zavtech,項目名稱:morpheus-core,代碼行數:8,代碼來源:SparseArrayWithIntCoding.java

示例13: readObject

import java.io.ObjectInputStream; //導入方法依賴的package包/類
@GwtIncompatible // java.io.ObjectInputStream
// Serialization type safety is at the caller's mercy.
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
  stream.defaultReadObject();
  Comparator<Object> valueComparator = (Comparator<Object>) stream.readObject();
  int keyCount = stream.readInt();
  if (keyCount < 0) {
    throw new InvalidObjectException("Invalid key count " + keyCount);
  }
  ImmutableMap.Builder<Object, ImmutableSet<Object>> builder = ImmutableMap.builder();
  int tmpSize = 0;

  for (int i = 0; i < keyCount; i++) {
    Object key = stream.readObject();
    int valueCount = stream.readInt();
    if (valueCount <= 0) {
      throw new InvalidObjectException("Invalid value count " + valueCount);
    }

    ImmutableSet.Builder<Object> valuesBuilder = valuesBuilder(valueComparator);
    for (int j = 0; j < valueCount; j++) {
      valuesBuilder.add(stream.readObject());
    }
    ImmutableSet<Object> valueSet = valuesBuilder.build();
    if (valueSet.size() != valueCount) {
      throw new InvalidObjectException("Duplicate key-value pairs exist for key " + key);
    }
    builder.put(key, valueSet);
    tmpSize += valueCount;
  }

  ImmutableMap<Object, ImmutableSet<Object>> tmpMap;
  try {
    tmpMap = builder.build();
  } catch (IllegalArgumentException e) {
    throw (InvalidObjectException) new InvalidObjectException(e.getMessage()).initCause(e);
  }

  FieldSettersHolder.MAP_FIELD_SETTER.set(this, tmpMap);
  FieldSettersHolder.SIZE_FIELD_SETTER.set(this, tmpSize);
  FieldSettersHolder.EMPTY_SET_FIELD_SETTER.set(this, emptySet(valueComparator));
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:44,代碼來源:ImmutableSetMultimap.java

示例14: populateMap

import java.io.ObjectInputStream; //導入方法依賴的package包/類
/**
 * Populates a map by reading an input stream, as part of deserialization.
 * See {@link #writeMap} for the data format.
 */
static <K, V> void populateMap(Map<K, V> map, ObjectInputStream stream)
    throws IOException, ClassNotFoundException {
  int size = stream.readInt();
  populateMap(map, stream, size);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:10,代碼來源:Serialization.java

示例15: readObject

import java.io.ObjectInputStream; //導入方法依賴的package包/類
@GwtIncompatible("java.io.ObjectInputStream")
// Serialization type safety is at the caller's mercy.
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream stream)
    throws IOException, ClassNotFoundException {
  stream.defaultReadObject();
  Comparator<Object> valueComparator =
      (Comparator<Object>) stream.readObject();
  int keyCount = stream.readInt();
  if (keyCount < 0) {
    throw new InvalidObjectException("Invalid key count " + keyCount);
  }
  ImmutableMap.Builder<Object, ImmutableSet<Object>> builder
      = ImmutableMap.builder();
  int tmpSize = 0;

  for (int i = 0; i < keyCount; i++) {
    Object key = stream.readObject();
    int valueCount = stream.readInt();
    if (valueCount <= 0) {
      throw new InvalidObjectException("Invalid value count " + valueCount);
    }

    Object[] array = new Object[valueCount];
    for (int j = 0; j < valueCount; j++) {
      array[j] = stream.readObject();
    }
    ImmutableSet<Object> valueSet = valueSet(valueComparator, asList(array));
    if (valueSet.size() != array.length) {
      throw new InvalidObjectException(
          "Duplicate key-value pairs exist for key " + key);
    }
    builder.put(key, valueSet);
    tmpSize += valueCount;
  }

  ImmutableMap<Object, ImmutableSet<Object>> tmpMap;
  try {
    tmpMap = builder.build();
  } catch (IllegalArgumentException e) {
    throw (InvalidObjectException)
        new InvalidObjectException(e.getMessage()).initCause(e);
  }

  FieldSettersHolder.MAP_FIELD_SETTER.set(this, tmpMap);
  FieldSettersHolder.SIZE_FIELD_SETTER.set(this, tmpSize);
  FieldSettersHolder.EMPTY_SET_FIELD_SETTER.set(
      this, emptySet(valueComparator));
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:50,代碼來源:ImmutableSetMultimap.java


注:本文中的java.io.ObjectInputStream.readInt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。