下面列出了java.io.ObjectInputStream#readDouble ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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.writeDouble(0.0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readDouble();
}
}
}
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
z = in.readBoolean();
b = in.readByte();
c = in.readChar();
s = in.readShort();
i = in.readInt();
f = in.readFloat();
j = in.readLong();
d = in.readDouble();
str = (String) in.readObject();
parent = in.readObject();
left = in.readObject();
right = in.readObject();
}
/**
* Reads a <code>Point2D</code> object that has been serialised by the
* {@link #writePoint2D(Point2D, ObjectOutputStream)} method.
*
* @param stream the input stream (<code>null</code> not permitted).
*
* @return The point object (possibly <code>null</code>).
*
* @throws IOException if there is an I/O problem.
*/
public static Point2D readPoint2D(final ObjectInputStream stream)
throws IOException {
if (stream == null) {
throw new IllegalArgumentException("Null 'stream' argument.");
}
Point2D result = null;
final boolean isNull = stream.readBoolean();
if (!isNull) {
final double x = stream.readDouble();
final double y = stream.readDouble();
result = new Point2D.Double(x, y);
}
return result;
}
/**
* 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.writeDouble(0.0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readDouble();
}
}
}
/**
* 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.writeDouble(0.0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readDouble();
}
}
}
void readObject(ObjectInputStream in) throws IOException {
nTotalInstrMethods = in.readInt();
nClassLoads = in.readInt();
nFirstMethodInvocations = in.readInt();
nNonEmptyInstrMethodGroupResponses = in.readInt();
nEmptyInstrMethodGroupResponses = in.readInt();
nSingleMethodInstrMethodGroupResponses = in.readInt();
clientInstrTime = in.readDouble();
clientDataProcTime = in.readDouble();
totalHotswappingTime = in.readDouble();
averageHotswappingTime = in.readDouble();
minHotswappingTime = in.readDouble();
maxHotswappingTime = in.readDouble();
methodEntryExitCallTime0 = in.readDouble();
methodEntryExitCallTime1 = in.readDouble();
methodEntryExitCallTime2 = in.readDouble();
}
/**
* 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.writeDouble(0.0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readDouble();
}
}
}
/**
* 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.writeDouble(0.0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readDouble();
}
}
}
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
z = in.readBoolean();
b = in.readByte();
c = in.readChar();
s = in.readShort();
i = in.readInt();
f = in.readFloat();
j = in.readLong();
d = in.readDouble();
str = (String) in.readObject();
parent = in.readObject();
left = in.readObject();
right = in.readObject();
}
/**
* 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.writeDouble(0.0);
}
oout.flush();
for (int j = 0; j < ncycles; j++) {
oin.readDouble();
}
}
}
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
int size = stream.readInt();
setUp(size);
while (size-- > 0) {
double key = stream.readDouble();
double val = stream.readDouble();
put(key, val);
}
}
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
int size = stream.readInt();
setUp(size);
while (size-- > 0) {
double key = stream.readDouble();
int val = stream.readInt();
put(key, val);
}
}
/** Deserialize a {@link RealMatrix} field in a class.
* <p>
* This method is intended to be called from within a private
* <code>readObject</code> method (after a call to
* <code>ois.defaultReadObject()</code>) in a class that has a
* {@link RealMatrix} field, which should be declared <code>transient</code>.
* This way, the default handling does not deserialize the matrix (the {@link
* RealMatrix} interface is not serializable by default) but this method does
* deserialize it specifically.
* </p>
* @param instance instance in which the field must be set up
* @param fieldName name of the field within the class (may be private and final)
* @param ois stream from which the real matrix should be read
* @exception ClassNotFoundException if a class in the stream cannot be found
* @exception IOException if object cannot be read from the stream
* @see #serializeRealMatrix(RealMatrix, ObjectOutputStream)
*/
public static void deserializeRealMatrix(final Object instance,
final String fieldName,
final ObjectInputStream ois)
throws ClassNotFoundException, IOException {
try {
// read the matrix data
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();
}
}
// create the instance
final RealMatrix matrix = new Array2DRowRealMatrix(data, false);
// set up the field
final java.lang.reflect.Field f =
instance.getClass().getDeclaredField(fieldName);
f.setAccessible(true);
f.set(instance, matrix);
} catch (NoSuchFieldException | IllegalAccessException e) {
IOException ioe = new IOException();
ioe.initCause(e);
throw ioe;
}
}
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
int size = stream.readInt();
setUp(size);
while (size-- > 0) {
double key = stream.readDouble();
float val = stream.readFloat();
put(key, val);
}
}
/**
* Reads the object from the object input stream.
*
* @param in the object input stream from where to read the serialized data.
* @return the generated object.
* @throws IOException if reading the stream failed.
* @throws ClassNotFoundException if serialized object class cannot be found.
*/
public Object readObject( final ObjectInputStream in )
throws IOException, ClassNotFoundException {
final double x = in.readDouble();
final double y = in.readDouble();
final double w = in.readDouble();
final double h = in.readDouble();
return new Ellipse2D.Double( x, y, w, h );
}
/**
* Reads the object from the object input stream.
*
* @param in the object input stream from where to read the serialized data.
* @return the generated object.
* @throws IOException if reading the stream failed.
* @throws ClassNotFoundException if serialized object class cannot be found.
*/
public Object readObject( final ObjectInputStream in )
throws IOException, ClassNotFoundException {
final double x1 = in.readDouble();
final double y1 = in.readDouble();
final double x2 = in.readDouble();
final double y2 = in.readDouble();
return new Line2D.Double( x1, y1, x2, y2 );
}
@Override
public final void read(ObjectInputStream is, int count) throws IOException {
for (int i=0; i<count; ++i) {
final double value = is.readDouble();
this.setDouble(i, value);
}
}
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
int size = stream.readInt();
setUp(size);
while (size-- > 0) {
double key = stream.readDouble();
long val = stream.readLong();
put(key, val);
}
}
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
int size = stream.readInt();
setUp(size);
while (size-- > 0) {
double key = stream.readDouble();
int val = stream.readInt();
put(key, val);
}
}
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
int size = stream.readInt();
setUp(size);
while (size-- > 0) {
double key = stream.readDouble();
Object val = stream.readObject();
put(key, val);
}
}