|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.InputStream
java.io.ObjectInputStream
public class ObjectInputStream
An ObjectInputStream can be used to load Java objects from a stream where the objects were saved using an ObjectOutputStream. Primitive data (ints, bytes, chars, etc) can also be loaded if the data was saved as primitive types as well. It is invalid to attempt to read an object as primitive data.
ObjectOutputStream,
ObjectInput,
Serializable,
Externalizable| Nested Class Summary | |
|---|---|
static class |
ObjectInputStream.GetField
Inner class to provide access to serializable fields |
(package private) static class |
ObjectInputStream.InputValidationDesc
|
| Field Summary |
|---|
| Constructor Summary | |
|---|---|
protected |
ObjectInputStream()
Constructs a new ObjectInputStream. |
|
ObjectInputStream(InputStream input)
Constructs a new ObjectInputStream on the InputStream input. |
| Method Summary | |
|---|---|
int |
available()
Returns the number of bytes of primitive data available from the receiver. |
void |
close()
Close this ObjectInputStream. |
void |
defaultReadObject()
Default method to read objects from the receiver. |
protected boolean |
enableResolveObject(boolean enable)
Enables/disables object replacement for the receiver. |
int |
read()
Reads a single byte from the receiver and returns the result as an int. |
int |
read(byte[] buffer,
int offset,
int length)
Reads at most length bytes from the receiver and stores
them in byte array buffer starting at offset
offset. |
boolean |
readBoolean()
Reads and returns primitive data of type boolean read from the receiver |
byte |
readByte()
Reads and returns primitive data of type byte read from the receiver |
char |
readChar()
Reads and returns primitive data of type char read from the receiver |
protected ObjectStreamClass |
readClassDescriptor()
Reads a new class descriptor from the receiver. |
double |
readDouble()
Reads and returns primitive data of type double read from the receiver |
ObjectInputStream.GetField |
readFields()
Reads the fields of the object being read from the stream. |
float |
readFloat()
Reads and returns primitive data of type float read from the receiver |
void |
readFully(byte[] buffer)
Reads bytes from the receiver into the byte array buffer. |
void |
readFully(byte[] buffer,
int offset,
int length)
Reads bytes from the receiver into the byte array buffer. |
int |
readInt()
Reads and returns primitive data of type int read from the receiver |
String |
readLine()
Deprecated. Use BufferedReader |
long |
readLong()
Reads and returns primitive data of type long read from the receiver |
Object |
readObject()
Read the next object from the receiver's underlying stream. |
protected Object |
readObjectOverride()
Method to be overriden by subclasses to read the next object from the receiver's underlying stream. |
short |
readShort()
Reads and returns primitive data of type short from the receiver |
protected void |
readStreamHeader()
Reads and validates the ObjectInputStream header from the receiver |
Object |
readUnshared()
Read the next unshared object from the receiver's underlying stream. |
int |
readUnsignedByte()
Reads and returns primitive data of type byte (unsigned) from the receiver |
int |
readUnsignedShort()
Reads and returns primitive data of type short (unsigned) from the receiver |
String |
readUTF()
Reads and returns primitive data of type String read in UTF format from the receiver |
void |
registerValidation(ObjectInputValidation object,
int priority)
Register object validator object to be executed to perform
validation of objects loaded from the receiver. |
protected Class<?> |
resolveClass(ObjectStreamClass osClass)
Loads the Java class corresponding to the class descriptor osClass(ObjectStreamClass) just read from the receiver. |
protected Object |
resolveObject(Object object)
If enableResolveObject() was activated, computes the
replacement object for the original object object and
returns the replacement. |
protected Class<?> |
resolveProxyClass(String[] interfaceNames)
Retrieves the proxy class corresponding to the interface names. |
int |
skipBytes(int length)
Skips length bytes of primitive data from the receiver. |
| Methods inherited from class java.io.InputStream |
|---|
mark, markSupported, read, reset, skip |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.io.ObjectInput |
|---|
read, skip |
| Constructor Detail |
|---|
protected ObjectInputStream()
throws IOException,
SecurityException
IOException - If not called from a subclass
SecurityException - If subclasses are not allowedSecurityManager.checkPermission(java.security.Permission)
public ObjectInputStream(InputStream input)
throws StreamCorruptedException,
IOException
input.
All reads are now filtered through this stream.
input - The non-null InputStream to filter reads on.
IOException - If an IO exception happened when reading the stream header.
StreamCorruptedException - If the underlying stream does not contain serialized objects
that can be read.| Method Detail |
|---|
public int available()
throws IOException
available in interface ObjectInputavailable in class InputStreamIOException - If any IO problem occurred when trying to compute the bytes
available.
public void close()
throws IOException
close in interface Closeableclose in interface ObjectInputclose in class InputStreamIOException - If an error occurs attempting to close this stream.
public void defaultReadObject()
throws IOException,
ClassNotFoundException,
NotActiveException
IOException - If an IO error occurs attempting to read the object data
ClassNotFoundException - If the class of the object cannot be found
NotActiveException - If this method is not called from readObject()ObjectOutputStream.defaultWriteObject()
protected boolean enableResolveObject(boolean enable)
throws SecurityException
enable - if true, enables replacement. If false, disables replacement.
SecurityException - If the class of the receiver is not trustedresolveObject(java.lang.Object),
ObjectOutputStream.enableReplaceObject(boolean)
public int read()
throws IOException
read in interface ObjectInputread in class InputStreamIOException - If an IO exception happened when reading the primitive data.
public int read(byte[] buffer,
int offset,
int length)
throws IOException
length bytes from the receiver and stores
them in byte array buffer starting at offset
offset. Answer the number of bytes actually read or -1 if
no bytes were read and end of stream was encountered.
read in interface ObjectInputread in class InputStreambuffer - the byte array in which to store the read bytes.offset - the offset in buffer to store the read bytes.length - the maximum number of bytes to store in buffer.
IOException - If an IO exception happened when reading the primitive data.
public boolean readBoolean()
throws IOException
readBoolean in interface DataInputObjectOutputStream.writeBoolean()
IOException - If an IO exception happened when reading the primitive data.DataOutput.writeBoolean(boolean)
public byte readByte()
throws IOException
readByte in interface DataInputObjectOutputStream.writeByte()
IOException - If an IO exception happened when reading the primitive data.DataOutput.writeByte(int)
public char readChar()
throws IOException
readChar in interface DataInputObjectOutputStream.writeChar()
IOException - If an IO exception happened when reading the primitive data.DataOutput.writeChar(int)
public double readDouble()
throws IOException
readDouble in interface DataInputObjectOutputStream.writeDouble()
IOException - If an IO exception happened when reading the primitive data.DataOutput.writeDouble(double)
public ObjectInputStream.GetField readFields()
throws IOException,
ClassNotFoundException,
NotActiveException
getField object, allowing
users to load emulated fields, for cross-loading compatibility when a
class definition changes.
IOException - If an IO exception happened
ClassNotFoundException - If a class of an object being de-serialized can not be found
NotActiveException - If there is no object currently being loaded (invalid to call
this method)
public float readFloat()
throws IOException
readFloat in interface DataInputObjectOutputStream.writeFloat()
IOException - If an IO exception happened when reading the primitive data.DataOutput.writeFloat(float)
public void readFully(byte[] buffer)
throws IOException
buffer.
This method will block until buffer.length number of bytes
have been read.
readFully in interface DataInputbuffer - the buffer to read bytes into
IOException - if a problem occurs reading from this stream.DataOutput.write(byte[]),
DataOutput.write(byte[], int, int)
public void readFully(byte[] buffer,
int offset,
int length)
throws IOException
buffer.
This method will block until length number of bytes have
been read.
readFully in interface DataInputbuffer - the byte array in which to store the read bytes.offset - the offset in buffer to store the read bytes.length - the maximum number of bytes to store in buffer.
IOException - if a problem occurs reading from this stream.DataOutput.write(byte[]),
DataOutput.write(byte[], int, int)
public int readInt()
throws IOException
readInt in interface DataInputObjectOutputStream.writeInt()
IOException - If an IO exception happened when reading the primitive data.DataOutput.writeInt(int)
@Deprecated
public String readLine()
throws IOException
BufferedReader
readLine in interface DataInputObjectOutputStream.writeLine()
IOException - If an IO exception happened when reading the primitive data.
public long readLong()
throws IOException
readLong in interface DataInputObjectOutputStream.writeLong()
IOException - If an IO exception happened when reading the primitive data.DataOutput.writeLong(long)
protected ObjectStreamClass readClassDescriptor()
throws IOException,
ClassNotFoundException
ObjectStreamClass read from the stream.
IOException - If an IO exception happened when reading the class
descriptor.
ClassNotFoundException - If a class for one of the objects could not be found
protected Class<?> resolveProxyClass(String[] interfaceNames)
throws IOException,
ClassNotFoundException
interfaceNames - The interfaces used to create the proxy class
IOException - If any IO problem occurred when trying to load the class.
ClassNotFoundException - If the proxy class cannot be created
public final Object readObject()
throws OptionalDataException,
ClassNotFoundException,
IOException
readObject in interface ObjectInputIOException - If an IO exception happened when reading the object
ClassNotFoundException - If the class of one of the objects in the object graph could
not be found
OptionalDataException - If primitive data types were found instead of an object.ObjectOutputStream.writeObject(Object)
public Object readUnshared()
throws IOException,
ClassNotFoundException
IOException - If an IO exception happened when reading the object
ClassNotFoundException - If the class of one of the objects in the object graph could
not be foundObjectOutputStream.writeUnshared(java.lang.Object)
protected Object readObjectOverride()
throws OptionalDataException,
ClassNotFoundException,
IOException
IOException - If an IO exception happened when reading the object
ClassNotFoundException - If the class of one of the objects in the object graph could
not be found
OptionalDataException - If primitive data types were found instead of an object.ObjectOutputStream.writeObjectOverride(java.lang.Object)
public short readShort()
throws IOException
readShort in interface DataInputObjectOutputStream.writeShort()
IOException - If an IO exception happened when reading the primitive data.DataOutput.writeShort(int)
protected void readStreamHeader()
throws IOException,
StreamCorruptedException
IOException - If an IO exception happened when reading the stream header.
StreamCorruptedException - If the underlying stream does not contain serialized objects
that can be read.
public int readUnsignedByte()
throws IOException
readUnsignedByte in interface DataInputObjectOutputStream.writeUnsignedByte()
IOException - If an IO exception happened when reading the primitive data.DataOutput.writeByte(int)
public int readUnsignedShort()
throws IOException
readUnsignedShort in interface DataInputObjectOutputStream.writeUnsignedShort()
IOException - If an IO exception happened when reading the primitive data.DataOutput.writeShort(int)
public String readUTF()
throws IOException
readUTF in interface DataInputObjectOutputStream.writeUTF()
IOException - If an IO exception happened when reading the primitive data.DataOutput.writeUTF(java.lang.String)
public void registerValidation(ObjectInputValidation object,
int priority)
throws NotActiveException,
InvalidObjectException
object to be executed to perform
validation of objects loaded from the receiver. Validations will be run
in order of decreasing priority, defined by priority.
object - An ObjectInputValidation to validate objects loaded.priority - validator priority
NotActiveException - If this method is not called from readObject()
InvalidObjectException - If object is null.
protected Class<?> resolveClass(ObjectStreamClass osClass)
throws IOException,
ClassNotFoundException
osClass(ObjectStreamClass) just read from the receiver.
osClass - An ObjectStreamClass read from the receiver.
IOException - If any IO problem occurred when trying to load the class.
ClassNotFoundException - If the corresponding class cannot be found.
protected Object resolveObject(Object object)
throws IOException
enableResolveObject() was activated, computes the
replacement object for the original object object and
returns the replacement. Otherwise returns object.
object - Original object for which a replacement may be defined
object
IOException - If any IO problem occurred when trying to resolve the object.enableResolveObject(boolean),
ObjectOutputStream.enableReplaceObject(boolean),
ObjectOutputStream.replaceObject(java.lang.Object)
public int skipBytes(int length)
throws IOException
length bytes of primitive data from the receiver. It
should not be used to skip bytes at any arbitrary position; just when
reading primitive data types (ints, chars, etc).
skipBytes in interface DataInputlength - How many bytes to skip
IOException - If any IO problem occurred when trying to skip the bytes.
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||