Java Reference
In-Depth Information
Display 10.15
Some Methods in the Class
ObjectInputStream
(part 2 of 3)
public int
readInt()
throws
IOException
Reads an
int
value from the input stream and returns that
int
value. If
readInt
tries to read
a value from the file and that value was not written using the method
writeInt
of the class
ObjectOutputStream
(or written in some equivalent way), then problems will occur. If an
attempt is made to read beyond the end of the file, an
EOFException
is thrown.
public int
readShort()
throws
IOException
Reads a
short
value from the input stream and returns that
short
value. If
readShort
tries to
read a value from the file and that value was not written using the method
writeShort
of the
class
ObjectOutputStream
(or written in some equivalent way), then problems will occur. If an
attempt is made to read beyond the end of the file, an
EOFException
is thrown.
public long
readLong()
throws
IOException
Reads a
long
value from the input stream and returns that
long
value. If
readLong
tries to
read a value from the file and that value was not written using the method
writeLong
of the
class
ObjectOutputStream
(or written in some equivalent way), then problems will occur. If an
attempt is made to read beyond the end of the file, an
EOFException
is thrown.
public double
readDouble()
throws
IOException
Reads a
double
value from the input stream and returns that
double
value. If
readDouble
tries
to read a value from the file and that value was not written using the method
writeDouble
of the
class
ObjectOutputStream
(or written in some equivalent way), then problems will occur. If an
attempt is made to read beyond the end of the file, an
EOFException
is thrown.
public float
readFloat()
throws
IOException
Reads a
float
value from the input stream and returns that
float
value. If
readFloat
tries to
read a value from the file and that value was not written using the method
writeFloat
of the
class
ObjectOutputStream
(or written in some equivalent way), then problems will occur. If an
attempt is made to read beyond the end of the file, an
EOFException
is thrown.
public char
readChar()
throws
IOException
Reads a
char
value from the input stream and returns that
char
value. If
readChar
tries to
read a value from the file and that value was not written using the method
writeChar
of the
class
ObjectOutputStream
(or written in some equivalent way), then problems will occur. If an
attempt is made to read beyond the end of the file, an
EOFException
is thrown.
public boolean
readBoolean()
throws
IOException
Reads a
boolean
value from the input stream and returns that
boolean
value. If
readBoolean
tries to read a value from the file and that value was not written using the method
writeBoolean
of the class
ObjectOutputStream
(or written in some equivalent way), then problems will
occur. If an attempt is made to read beyond the end of the file, an
EOFException
is thrown.
(continued)