本文整理汇总了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();
}
}
}
示例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);
}
}
}
示例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();
}
}
示例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);
}
示例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();
}
示例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);
}
示例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 ) );
}
示例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();
}
}
示例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);
}
}
示例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());
}
}
示例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);
}
示例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);
}
}
示例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));
}
示例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);
}
示例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));
}