Save This Page
Home » apache-harmony-6.0-src-r917296-snapshot » java » io » [javadoc | source]
java.io
public class: ObjectInputStream [javadoc | source]
java.lang.Object
   java.io.InputStream
      java.io.ObjectInputStream

All Implemented Interfaces:
    ObjectInput, ObjectStreamConstants, Closeable

Direct Known Subclasses:
    CustomizedObjectInputStream

A specialized InputStream that is able to read (deserialize) Java objects as well as primitive data types (int, byte, char etc.). The data has typically been saved using an ObjectOutputStream.
Nested Class Summary:
static class  ObjectInputStream.InputValidationDesc   
abstract public static class  ObjectInputStream.GetField  GetField is an inner class that provides access to the persistent fields read from the source stream. 
Constructor:
 protected ObjectInputStream() throws IOException, SecurityException 
    Constructs a new ObjectInputStream. This default constructor can be used by subclasses that do not want to use the public constructor if it allocates unneeded data.
    Throws:
    IOException - if an error occurs when creating this stream.
    SecurityException - if a security manager is installed and it denies subclassing this class.
    Also see:
    SecurityManager#checkPermission(java.security.Permission)
 public ObjectInputStream(InputStream input) throws StreamCorruptedException, IOException 
    Constructs a new ObjectInputStream that reads from the InputStream {@code input}.
    Parameters:
    input - the non-null source InputStream to filter reads on.
    Throws:
    IOException - if an error occurs while reading the stream header.
    StreamCorruptedException - if the source stream does not contain serialized objects that can be read.
    SecurityException - if a security manager is installed and it denies subclassing this class.
Method from java.io.ObjectInputStream Summary:
available,   close,   defaultReadObject,   enableResolveObject,   read,   read,   readBoolean,   readByte,   readChar,   readClassDescriptor,   readDouble,   readFields,   readFloat,   readFully,   readFully,   readInt,   readLine,   readLong,   readObject,   readObjectOverride,   readShort,   readStreamHeader,   readUTF,   readUnshared,   readUnsignedByte,   readUnsignedShort,   registerValidation,   resolveClass,   resolveObject,   resolveProxyClass,   skipBytes
Methods from java.io.InputStream:
available,   close,   mark,   markSupported,   read,   read,   read,   reset,   skip
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.io.ObjectInputStream Detail:
 public int available() throws IOException 
    Returns the number of bytes of primitive data that can be read from this stream without blocking. This method should not be used at any arbitrary position; just when reading primitive data types (int, char etc).
 public  void close() throws IOException 
    Closes this stream. This implementation closes the source stream.
 public  void defaultReadObject() throws IOException, ClassNotFoundException, NotActiveException 
    Default method to read objects from this stream. Serializable fields defined in the object's class and superclasses are read from the source stream.
 protected boolean enableResolveObject(boolean enable) throws SecurityException 
    Enables object replacement for this stream. By default this is not enabled. Only trusted subclasses (loaded with system class loader) are allowed to change this status.
 public int read() throws IOException 
    Reads a single byte from the source stream and returns it as an integer in the range from 0 to 255. Returns -1 if the end of the source stream has been reached. Blocks if no input is available.
 public int read(byte[] buffer,
    int offset,
    int length) throws IOException 
    Reads at most {@code length} bytes from the source stream and stores them in byte array {@code buffer} starting at offset {@code count}. Blocks until {@code count} bytes have been read, the end of the source stream is detected or an exception is thrown.
 public boolean readBoolean() throws IOException 
    Reads a boolean from the source stream.
 public byte readByte() throws IOException 
    Reads a byte (8 bit) from the source stream.
 public char readChar() throws IOException 
    Reads a character (16 bit) from the source stream.
 protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException 
    Reads a class descriptor from the source stream.
 public double readDouble() throws IOException 
    Reads a double (64 bit) from the source stream.
 public GetField readFields() throws IOException, ClassNotFoundException, NotActiveException 
    Reads the persistent fields of the object that is currently being read from the source stream. The values read are stored in a GetField object that provides access to the persistent fields. This GetField object is then returned.
 public float readFloat() throws IOException 
    Reads a float (32 bit) from the source stream.
 public  void readFully(byte[] buffer) throws IOException 
    Reads bytes from the source stream into the byte array {@code buffer}. This method will block until {@code buffer.length} bytes have been read.
 public  void readFully(byte[] buffer,
    int offset,
    int length) throws IOException 
    Reads bytes from the source stream into the byte array {@code buffer}. This method will block until {@code length} number of bytes have been read.
 public int readInt() throws IOException 
    Reads an integer (32 bit) from the source stream.
 public String readLine() throws IOException 
Deprecated! Use - BufferedReader

    Reads the next line from the source stream. Lines are terminated by {@code '\r'}, {@code '\n'}, {@code "\r\n"} or an {@code EOF}.
 public long readLong() throws IOException 
    Reads a long (64 bit) from the source stream.
 public final Object readObject() throws OptionalDataException, ClassNotFoundException, IOException 
    Reads the next object from the source stream.
 protected Object readObjectOverride() throws OptionalDataException, ClassNotFoundException, IOException 
    Method to be overriden by subclasses to read the next object from the source stream.
 public short readShort() throws IOException 
    Reads a short (16 bit) from the source stream.
 protected  void readStreamHeader() throws IOException, StreamCorruptedException 
    Reads and validates the ObjectInputStream header from the source stream.
 public String readUTF() throws IOException 
 public Object readUnshared() throws IOException, ClassNotFoundException 
    Reads the next unshared object from the source stream.
 public int readUnsignedByte() throws IOException 
    Reads an unsigned byte (8 bit) from the source stream.
 public int readUnsignedShort() throws IOException 
    Reads an unsigned short (16 bit) from the source stream.
 public synchronized  void registerValidation(ObjectInputValidation object,
    int priority) throws NotActiveException, InvalidObjectException 
    Registers a callback for post-deserialization validation of objects. It allows to perform additional consistency checks before the {@code readObject()} method of this class returns its result to the caller. This method can only be called from within the {@code readObject()} method of a class that implements "special" deserialization rules. It can be called multiple times. Validation callbacks are then done in order of decreasing priority, defined by {@code priority}.
 protected Class<?> resolveClass(ObjectStreamClass osClass) throws IOException, ClassNotFoundException 
    Loads the Java class corresponding to the class descriptor {@code osClass} that has just been read from the source stream.
 protected Object resolveObject(Object object) throws IOException 
    Allows trusted subclasses to substitute the specified original {@code object} with a new object. Object substitution has to be activated first with calling {@code enableResolveObject(true)}. This implementation just returns {@code object}.
 protected Class<?> resolveProxyClass(String[] interfaceNames) throws IOException, ClassNotFoundException 
    Creates the proxy class that implements the interfaces specified in {@code interfaceNames}.
 public int skipBytes(int length) throws IOException 
    Skips {@code length} bytes on the source stream. This method should not be used to skip bytes at any arbitrary position, just when reading primitive data types (int, char etc).