本文整理汇总了Java中java.io.ObjectInputStream.read方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectInputStream.read方法的具体用法?Java ObjectInputStream.read怎么用?Java ObjectInputStream.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.ObjectInputStream
的用法示例。
在下文中一共展示了ObjectInputStream.read方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
private void readObject(ObjectInputStream in) throws IOException
{
int len = in.readInt();
byte[] buffer = new byte[len];
int readSoFar = 0;
while (readSoFar < len)
{
readSoFar += in.read(buffer, readSoFar, len - readSoFar);
}
this.contents = new String(buffer, JrpipServiceRegistry.ENCODE_STRING);
}
示例2: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
* Deserializes an {@link MBeanFeatureInfo} from an {@link ObjectInputStream}.
* @serialData
* For compatibility reasons, an object of this class is deserialized as follows.
* <p>
* The method {@link ObjectInputStream#defaultReadObject defaultReadObject()}
* is called first to deserialize the object except the field
* {@code descriptor}, which is not serialized in the default way. Then the method
* {@link ObjectInputStream#read read()} is called to read a byte, the field
* {@code descriptor} is deserialized according to the value of the byte value:
* <ul>
* <li>1. The method {@link ObjectInputStream#readObject readObject()}
* is called twice to obtain the field names (a {@code String[]}) and
* the field values (a {@code Object[]}) of the {@code descriptor}.
* The two obtained values then are used to construct
* an {@link ImmutableDescriptor} instance for the field
* {@code descriptor};</li>
* <li>0. The value for the field {@code descriptor} is obtained directly
* by calling the method {@link ObjectInputStream#readObject readObject()}.
* If the obtained value is null, the field {@code descriptor} is set to
* {@link ImmutableDescriptor#EMPTY_DESCRIPTOR EMPTY_DESCRIPTOR};</li>
* <li>-1. This means that there is no byte to read and that the object is from
* an earlier version of the JMX API. The field {@code descriptor} is set
* to {@link ImmutableDescriptor#EMPTY_DESCRIPTOR EMPTY_DESCRIPTOR}</li>
* <li>Any other value. A {@link StreamCorruptedException} is thrown.</li>
* </ul>
*
* @since 1.6
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
in.defaultReadObject();
switch (in.read()) {
case 1:
final String[] names = (String[])in.readObject();
final Object[] values = (Object[]) in.readObject();
descriptor = (names.length == 0) ?
ImmutableDescriptor.EMPTY_DESCRIPTOR :
new ImmutableDescriptor(names, values);
break;
case 0:
descriptor = (Descriptor)in.readObject();
if (descriptor == null) {
descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
}
break;
case -1: // from an earlier version of the JMX API
descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
break;
default:
throw new StreamCorruptedException("Got unexpected byte.");
}
}
示例3: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
* Deserializes an {@link MBeanInfo} from an {@link ObjectInputStream}.
* @serialData
* For compatibility reasons, an object of this class is deserialized as follows.
* <p>
* The method {@link ObjectInputStream#defaultReadObject defaultReadObject()}
* is called first to deserialize the object except the field
* {@code descriptor}, which is not serialized in the default way. Then the method
* {@link ObjectInputStream#read read()} is called to read a byte, the field
* {@code descriptor} is deserialized according to the value of the byte value:
* <ul>
* <li>1. The method {@link ObjectInputStream#readObject readObject()}
* is called twice to obtain the field names (a {@code String[]}) and
* the field values (a {@code Object[]}) of the {@code descriptor}.
* The two obtained values then are used to construct
* an {@link ImmutableDescriptor} instance for the field
* {@code descriptor};</li>
* <li>0. The value for the field {@code descriptor} is obtained directly
* by calling the method {@link ObjectInputStream#readObject readObject()}.
* If the obtained value is null, the field {@code descriptor} is set to
* {@link ImmutableDescriptor#EMPTY_DESCRIPTOR EMPTY_DESCRIPTOR};</li>
* <li>-1. This means that there is no byte to read and that the object is from
* an earlier version of the JMX API. The field {@code descriptor} is set to
* {@link ImmutableDescriptor#EMPTY_DESCRIPTOR EMPTY_DESCRIPTOR}.</li>
* <li>Any other value. A {@link StreamCorruptedException} is thrown.</li>
* </ul>
*
* @since 1.6
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
in.defaultReadObject();
switch (in.read()) {
case 1:
final String[] names = (String[])in.readObject();
final Object[] values = (Object[]) in.readObject();
descriptor = (names.length == 0) ?
ImmutableDescriptor.EMPTY_DESCRIPTOR :
new ImmutableDescriptor(names, values);
break;
case 0:
descriptor = (Descriptor)in.readObject();
if (descriptor == null) {
descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
}
break;
case -1: // from an earlier version of the JMX API
descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
break;
default:
throw new StreamCorruptedException("Got unexpected byte.");
}
}
示例4: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
* Deserializes an {@link MBeanFeatureInfo} from an {@link ObjectInputStream}.
* @serialData
* For compatibility reasons, an object of this class is deserialized as follows.
* <p>
* The method {@link ObjectInputStream#defaultReadObject defaultReadObject()}
* is called first to deserialize the object except the field
* {@code descriptor}, which is not serialized in the default way. Then the method
* {@link ObjectInputStream#read read()} is called to read a byte, the field
* {@code descriptor} is deserialized according to the value of the byte value:
* <ul>
* <li>1. The method {@link ObjectInputStream#readObject readObject()}
* is called twice to obtain the field names (a {@code String[]}) and
* the field values (an {@code Object[]}) of the {@code descriptor}.
* The two obtained values then are used to construct
* an {@link ImmutableDescriptor} instance for the field
* {@code descriptor};</li>
* <li>0. The value for the field {@code descriptor} is obtained directly
* by calling the method {@link ObjectInputStream#readObject readObject()}.
* If the obtained value is null, the field {@code descriptor} is set to
* {@link ImmutableDescriptor#EMPTY_DESCRIPTOR EMPTY_DESCRIPTOR};</li>
* <li>-1. This means that there is no byte to read and that the object is from
* an earlier version of the JMX API. The field {@code descriptor} is set
* to {@link ImmutableDescriptor#EMPTY_DESCRIPTOR EMPTY_DESCRIPTOR}</li>
* <li>Any other value. A {@link StreamCorruptedException} is thrown.</li>
* </ul>
*
* @since 1.6
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
in.defaultReadObject();
switch (in.read()) {
case 1:
final String[] names = (String[])in.readObject();
final Object[] values = (Object[]) in.readObject();
descriptor = (names.length == 0) ?
ImmutableDescriptor.EMPTY_DESCRIPTOR :
new ImmutableDescriptor(names, values);
break;
case 0:
descriptor = (Descriptor)in.readObject();
if (descriptor == null) {
descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
}
break;
case -1: // from an earlier version of the JMX API
descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
break;
default:
throw new StreamCorruptedException("Got unexpected byte.");
}
}
示例5: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
/**
* Deserializes an {@link MBeanInfo} from an {@link ObjectInputStream}.
* @serialData
* For compatibility reasons, an object of this class is deserialized as follows.
* <p>
* The method {@link ObjectInputStream#defaultReadObject defaultReadObject()}
* is called first to deserialize the object except the field
* {@code descriptor}, which is not serialized in the default way. Then the method
* {@link ObjectInputStream#read read()} is called to read a byte, the field
* {@code descriptor} is deserialized according to the value of the byte value:
* <ul>
* <li>1. The method {@link ObjectInputStream#readObject readObject()}
* is called twice to obtain the field names (a {@code String[]}) and
* the field values (an {@code Object[]}) of the {@code descriptor}.
* The two obtained values then are used to construct
* an {@link ImmutableDescriptor} instance for the field
* {@code descriptor};</li>
* <li>0. The value for the field {@code descriptor} is obtained directly
* by calling the method {@link ObjectInputStream#readObject readObject()}.
* If the obtained value is null, the field {@code descriptor} is set to
* {@link ImmutableDescriptor#EMPTY_DESCRIPTOR EMPTY_DESCRIPTOR};</li>
* <li>-1. This means that there is no byte to read and that the object is from
* an earlier version of the JMX API. The field {@code descriptor} is set to
* {@link ImmutableDescriptor#EMPTY_DESCRIPTOR EMPTY_DESCRIPTOR}.</li>
* <li>Any other value. A {@link StreamCorruptedException} is thrown.</li>
* </ul>
*
* @since 1.6
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
in.defaultReadObject();
switch (in.read()) {
case 1:
final String[] names = (String[])in.readObject();
final Object[] values = (Object[]) in.readObject();
descriptor = (names.length == 0) ?
ImmutableDescriptor.EMPTY_DESCRIPTOR :
new ImmutableDescriptor(names, values);
break;
case 0:
descriptor = (Descriptor)in.readObject();
if (descriptor == null) {
descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
}
break;
case -1: // from an earlier version of the JMX API
descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
break;
default:
throw new StreamCorruptedException("Got unexpected byte.");
}
}
示例6: readObject
import java.io.ObjectInputStream; //导入方法依赖的package包/类
void readObject(ObjectInputStream in) throws IOException {
nClasses = in.readInt();
if (nClasses == 0) {
return;
}
if ((instrMethodClasses == null) || (nClasses > instrMethodClasses.length)) {
instrMethodClasses = new String[nClasses];
instrMethodClassLoaderIds = new int[nClasses];
}
for (int i = 0; i < nClasses; i++) {
instrMethodClasses[i] = in.readUTF();
instrMethodClassLoaderIds[i] = in.readInt();
}
nMethods = in.readInt();
int code = in.read();
if (code != 0) {
if ((instrMethodLeaf == null) || (nMethods > instrMethodLeaf.length)) {
instrMethodLeaf = new boolean[nMethods];
}
for (int i = 0; i < nMethods; i++) {
instrMethodLeaf[i] = in.readBoolean();
}
} else {
instrMethodLeaf = null;
}
addInfo = in.readInt();
if ((replacementClassFileBytes == null) || (nClasses > replacementClassFileBytes.length)) {
replacementClassFileBytes = new byte[nClasses][];
}
for (int i = 0; i < nClasses; i++) {
int len = in.readInt();
if (len > 0) {
replacementClassFileBytes[i] = new byte[len];
in.readFully(replacementClassFileBytes[i]);
}
}
}