java.io

Class ObjectInputStream

Implemented Interfaces:
Closeable, DataInput, ObjectInput, ObjectStreamConstants
Known Direct Subclasses:
ClassLoaderObjectInputStream, CodebaseAwareObjectInputStream, JRAbstractLRUVirtualizer.ClassLoaderAnnotationObjectInputStream

public class ObjectInputStream
extends InputStream
implements ObjectInput, ObjectStreamConstants

An ObjectInputStream deserializes primitive data and objects previously written using an ObjectOutputStream.

ObjectOutputStream and ObjectInputStream can provide an application with persistent storage for graphs of objects when used with a FileOutputStream and FileInputStream respectively. ObjectInputStream is used to recover those objects previously serialized. Other uses include passing objects between hosts using a socket stream or for marshaling and unmarshaling arguments and parameters in a remote communication system.

ObjectInputStream ensures that the types of all objects in the graph created from the stream match the classes present in the Java Virtual Machine. Classes are loaded as required using the standard mechanisms.

Only objects that support the java.io.Serializable or java.io.Externalizable interface can be read from streams.

The method readObject is used to read an object from the stream. Java's safe casting should be used to get the desired type. In Java, strings and arrays are objects and are treated as objects during serialization. When read they need to be cast to the expected type.

Primitive data types can be read from the stream using the appropriate method on DataInput.

The default deserialization mechanism for objects restores the contents of each field to the value and type it had when it was written. Fields declared as transient or static are ignored by the deserialization process. References to other objects cause those objects to be read from the stream as necessary. Graphs of objects are restored correctly using a reference sharing mechanism. New objects are always allocated when deserializing, which prevents existing objects from being overwritten.

Reading an object is analogous to running the constructors of a new object. Memory is allocated for the object and initialized to zero (NULL). No-arg constructors are invoked for the non-serializable classes and then the fields of the serializable classes are restored from the stream starting with the serializable class closest to java.lang.object and finishing with the object's most specific class.

For example to read from a stream as written by the example in ObjectOutputStream:

	FileInputStream fis = new FileInputStream("t.tmp");
	ObjectInputStream ois = new ObjectInputStream(fis);

	int i = ois.readInt();
	String today = (String) ois.readObject();
	Date date = (Date) ois.readObject();

	ois.close();
 

Classes control how they are serialized by implementing either the java.io.Serializable or java.io.Externalizable interfaces.

Implementing the Serializable interface allows object serialization to save and restore the entire state of the object and it allows classes to evolve between the time the stream is written and the time it is read. It automatically traverses references between objects, saving and restoring entire graphs.

Serializable classes that require special handling during the serialization and deserialization process should implement the following methods:

 private void writeObject(java.io.ObjectOutputStream stream)
     throws IOException;
 private void readObject(java.io.ObjectInputStream stream)
     throws IOException, ClassNotFoundException; 
 private void readObjectNoData() 
     throws ObjectStreamException;
 

The readObject method is responsible for reading and restoring the state of the object for its particular class using data written to the stream by the corresponding writeObject method. The method does not need to concern itself with the state belonging to its superclasses or subclasses. State is restored by reading data from the ObjectInputStream for the individual fields and making assignments to the appropriate fields of the object. Reading primitive data types is supported by DataInput.

Any attempt to read object data which exceeds the boundaries of the custom data written by the corresponding writeObject method will cause an OptionalDataException to be thrown with an eof field value of true. Non-object reads which exceed the end of the allotted data will reflect the end of data in the same way that they would indicate the end of the stream: bytewise reads will return -1 as the byte read or number of bytes read, and primitive reads will throw EOFExceptions. If there is no corresponding writeObject method, then the end of default serialized data marks the end of the allotted data.

Primitive and object read calls issued from within a readExternal method behave in the same manner--if the stream is already positioned at the end of data written by the corresponding writeExternal method, object reads will throw OptionalDataExceptions with eof set to true, bytewise reads will return -1, and primitive reads will throw EOFExceptions. Note that this behavior does not hold for streams written with the old ObjectStreamConstants.PROTOCOL_VERSION_1 protocol, in which the end of data written by writeExternal methods is not demarcated, and hence cannot be detected.

The readObjectNoData method is responsible for initializing the state of the object for its particular class in the event that the serialization stream does not list the given class as a superclass of the object being deserialized. This may occur in cases where the receiving party uses a different version of the deserialized instance's class than the sending party, and the receiver's version extends classes that are not extended by the sender's version. This may also occur if the serialization stream has been tampered; hence, readObjectNoData is useful for initializing deserialized objects properly despite a "hostile" or incomplete source stream.

Serialization does not read or assign values to the fields of any object that does not implement the java.io.Serializable interface. Subclasses of Objects that are not serializable can be serializable. In this case the non-serializable class must have a no-arg constructor to allow its fields to be initialized. In this case it is the responsibility of the subclass to save and restore the state of the non-serializable class. It is frequently the case that the fields of that class are accessible (public, package, or protected) or that there are get and set methods that can be used to restore the state.

Any exception that occurs while deserializing an object will be caught by the ObjectInputStream and abort the reading process.

Implementing the Externalizable interface allows the object to assume complete control over the contents and format of the object's serialized form. The methods of the Externalizable interface, writeExternal and readExternal, are called to save and restore the objects state. When implemented by a class they can write and read their own state using all of the methods of ObjectOutput and ObjectInput. It is the responsibility of the objects to handle any versioning that occurs.

Enum constants are deserialized differently than ordinary serializable or externalizable objects. The serialized form of an enum constant consists solely of its name; field values of the constant are not transmitted. To deserialize an enum constant, ObjectInputStream reads the constant name from the stream; the deserialized constant is then obtained by calling the static method Enum.valueOf(Class, String) with the enum constant's base type and the received constant name as arguments. Like other serializable or externalizable objects, enum constants can function as the targets of back references appearing subsequently in the serialization stream. The process by which enum constants are deserialized cannot be customized: any class-specific readObject, readObjectNoData, and readResolve methods defined by enum types are ignored during deserialization. Similarly, any serialPersistentFields or serialVersionUID field declarations are also ignored--all enum types have a fixed serialVersionUID of 0L.

Since:
JDK1.1
See Also:
DataInput, ObjectOutputStream, Serializable, Object Serialization Specification, Section 3, Object Input Classes

Nested Class Summary

static class
ObjectInputStream.GetField
Provide access to the persistent fields read from the input stream.

Fields inherited from interface java.io.ObjectStreamConstants

PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING, baseWireHandle

Constructor Summary

ObjectInputStream()
Provide a way for subclasses that are completely reimplementing ObjectInputStream to not have to allocate private data just used by this implementation of ObjectInputStream.
ObjectInputStream(InputStream in)
Creates an ObjectInputStream that reads from the specified InputStream.

Method Summary

@Deprecated
String readLine()
Deprecated. This method does not properly convert bytes to characters.
int
available()
Returns the number of bytes that can be read without blocking.
void
close()
Closes the input stream.
void
defaultReadObject()
Read the non-static and non-transient fields of the current class from this stream.
protected boolean
enableResolveObject(boolean enable)
Enable the stream to allow objects read from the stream to be replaced.
int
read()
Reads a byte of data.
int
read(byte[] buf, int off, int len)
Reads into an array of bytes.
boolean
readBoolean()
Reads in a boolean.
byte
readByte()
Reads an 8 bit byte.
char
readChar()
Reads a 16 bit char.
protected ObjectStreamClass
readClassDescriptor()
Read a class descriptor from the serialization stream.
double
readDouble()
Reads a 64 bit double.
ObjectInputStream.GetField
readFields()
Reads the persistent fields from the stream and makes them available by name.
float
readFloat()
Reads a 32 bit float.
void
readFully(byte[] buf)
Reads bytes, blocking until all bytes are read.
void
readFully(byte[] buf, int off, int len)
Reads bytes, blocking until all bytes are read.
int
readInt()
Reads a 32 bit int.
long
readLong()
Reads a 64 bit long.
Object
readObject()
Read an object from the ObjectInputStream.
protected Object
readObjectOverride()
This method is called by trusted subclasses of ObjectOutputStream that constructed ObjectOutputStream using the protected no-arg constructor.
short
readShort()
Reads a 16 bit short.
protected void
readStreamHeader()
The readStreamHeader method is provided to allow subclasses to read and verify their own stream headers.
String
readUTF()
Reads a String in modified UTF-8 format.
Object
readUnshared()
Reads an "unshared" object from the ObjectInputStream.
int
readUnsignedByte()
Reads an unsigned 8 bit byte.
int
readUnsignedShort()
Reads an unsigned 16 bit short.
void
registerValidation(ObjectInputValidation obj, int prio)
Register an object to be validated before the graph is returned.
protected Class
resolveClass(ObjectStreamClass desc)
Load the local class equivalent of the specified stream class description.
protected Object
resolveObject(Object obj)
This method will allow trusted subclasses of ObjectInputStream to substitute one object for another during deserialization.
protected Class
resolveProxyClass(String[] interfaces)
Returns a proxy class that implements the interfaces named in a proxy class descriptor; subclasses may implement this method to read custom data from the stream along with the descriptors for dynamic proxy classes, allowing them to use an alternate loading mechanism for the interfaces and the proxy class.
int
skipBytes(int len)
Skips bytes, block until all bytes are skipped.

Methods inherited from class java.io.InputStream

available, close, mark, markSupported, read, read, read, reset, skip

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

ObjectInputStream

protected ObjectInputStream()
            throws IOException,
                   SecurityException
Provide a way for subclasses that are completely reimplementing ObjectInputStream to not have to allocate private data just used by this implementation of ObjectInputStream.

If there is a security manager installed, this method first calls the security manager's checkPermission method with the SerializablePermission("enableSubclassImplementation") permission to ensure it's ok to enable subclassing.

Throws:
SecurityException - if a security manager exists and its checkPermission method denies enabling subclassing.
See Also:
SecurityManager.checkPermission, SerializablePermission

ObjectInputStream

public ObjectInputStream(InputStream in)
            throws IOException
Creates an ObjectInputStream that reads from the specified InputStream. A serialization stream header is read from the stream and verified. This constructor will block until the corresponding ObjectOutputStream has written and flushed the header.

If a security manager is installed, this constructor will check for the "enableSubclassImplementation" SerializablePermission when invoked directly or indirectly by the constructor of a subclass which overrides the ObjectInputStream.readFields or ObjectInputStream.readUnshared methods.

Parameters:
in - input stream to read from
Throws:
IOException - if an I/O error occurs while reading stream header
SecurityException - if untrusted subclass illegally overrides security-sensitive methods
NullPointerException - if in is null
Usages and Demos :

View More Examples of ObjectInputStream(InputStream in)
   1:         
   2:         ObjectInputStream objectIn=new ObjectInputStream((InputStream) dataIn);
   3:         try{
   4:             return objectIn.readObject();
   5:         } catch(ClassNotFoundException e) {

View Full Code Here
   1:         super(anObjStream);
   2:         theAnnotations = new ObjectInputStream(anAnnStream);
   3:         theLoader = aLoader;
   4:         requireIntegrityCheck = checkIntegrity;

View Full Code Here
   1:       java.io.ObjectInputStream ois = 
   2:         new java.io.ObjectInputStream(bais);
   3:       PropertyTree newPT = (PropertyTree)ois.readObject();
   4:       ois.close();
   5:       assertEquals("piped", 

View Full Code Here
   1:         {
   2:             ObjectInputStream is = new ObjectInputStream(SUtil.getResource("highscore.dmp"));
   3:             creatures = SUtil.arrayToList(is.readObject());
   4:             is.close();
   5:         }

View Full Code Here
   1:             previous = tokenReceiver.accept();
   2:             ios = new ObjectInputStream((previous.getInputStream()));
   3: 
   4:          }
   5:          previous.setSoTimeout(timeout);

View Full Code Here

Method Details

String readLine

public @Deprecated String readLine()
            throws IOException

Deprecated. This method does not properly convert bytes to characters. see DataInputStream for the details and alternatives.

Reads in a line that has been terminated by a \n, \r, \r\n or EOF.
Returns:
a String copy of the line.
Throws:
IOException - if there are I/O errors while reading from the underlying InputStream

available

public int available()
            throws IOException
Returns the number of bytes that can be read without blocking.
Specified by:
available in interface ObjectInput
Overrides:
available in interface InputStream
Returns:
the number of available bytes.
Throws:
IOException - if there are I/O errors while reading from the underlying InputStream
Usages and Demos :

View More Examples of available()
   1:     {
   2:         ObjectInputStream in = null;
   3:         try {
   4:         ...
   5:             in = new ObjectInputStream(new FileInputStream(keyFile));
   6:         ...
   7:             while (in.available() > 0) {
   8:                 long hash = in.readLong();

View Full Code Here
   1:       ProgressMonitorInputStream pmis = null;
   2:       ObjectInputStream oistream = null;
   3:       FileInputStream fistream = null;
   4:         ...
   5:          java.util.zip.GZIPInputStream zipIn = new java.util.zip.GZIPInputStream(pmis);
   6:          oistream = new ObjectInputStream(zipIn);
   7:         ...
   8:          oistream.available();
   9:          isZip = true;
  10:         ...
  11:             bfistream = new BufferedInputStream(pmis);
  12:             oistream = new ObjectInputStream(bfistream);

View Full Code Here
   1:             java.util.zip.GZIPInputStream zipIn = new java.util.zip.GZIPInputStream(fistream);
   2:             ObjectInputStream oistream = new ObjectInputStream(zipIn);
   3:         ...
   4:             oistream.available();
   5:             adminInfo = (AdminInfo)(oistream.readObject());
   6:             oistream.close();
   7:          }

View Full Code Here
   1: 
   2:       ObjectInputStream oistream = null;
   3:       ProgressMonitorInputStream pmis = null;
   4:         ...
   5:          java.util.zip.GZIPInputStream zipIn = new java.util.zip.GZIPInputStream(pmis);
   6:          oistream = new ObjectInputStream(zipIn);
   7:         ...
   8:          oistream.available();
   9:          isZip = true;
  10:         ...
  11:             bfistream = new BufferedInputStream(pmis);
  12:             oistream = new ObjectInputStream(bfistream);

View Full Code Here

close

public void close()
            throws IOException
Closes the input stream. Must be called to release any resources associated with the stream.
Specified by:
close in interface ObjectInput
close in interface Closeable
Overrides:
close in interface InputStream
Throws:
IOException - If an I/O error has occurred.
Usages and Demos :

View More Examples of close()
   1:     System.out.println("begin restore");
   2:     ObjectInputStream in=new ObjectInputStream(new FileInputStream("objFile"));
   3:     Serial sObj=(Serial)in.readObject();
   4:         ...
   5:     in.close();
   6:     System.out.println("data when restore="+new Date());
   7:   }
   8: }

View Full Code Here
   1:         FileInputStream in = new FileInputStream("test");
   2:         ObjectInputStream s = new ObjectInputStream(in);
   3:         String today = (String)s.readObject();
   4:         ...
   5:     System.out.print(date.toString());
   6:     in.close();
   7:         ...
   8:     s.close();
   9:     }

View Full Code Here
   1: {
   2:      ObjectInputStream in=new ObjectInputStream(new FileInputStream("filename"));
   3:     String today=(String)(in.readObject());
   4:         ...
   5:     System.out.println(s);
   6:     in.close();
   7: }
   8: }

View Full Code Here
   1:         FileInputStream fis = new FileInputStream("sb.ser");
   2:         ObjectInputStream ois = new ObjectInputStream(fis);
   3: 
   4:         ...
   5: 
   6:         ois.close();
   7: 
   8:     } catch (IOException ioException) {
   9:         System.out.println(ioException);

View Full Code Here
   1:     
   2:     ObjectInputStream oi = new ObjectInputStream(
   3:       new FileInputStream( filename ) );
   4:         ...
   5:     SerMe o = (SerMe) oi.readObject();
   6:     oi.close();
   7:   }
   8: }

View Full Code Here

defaultReadObject

public void defaultReadObject()
            throws IOException,
                   ClassNotFoundException
Read the non-static and non-transient fields of the current class from this stream. This may only be called from the readObject method of the class being deserialized. It will throw the NotActiveException if it is called otherwise.
Throws:
ClassNotFoundException - if the class of a serialized object could not be found.
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of defaultReadObject()
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5:     private void writeObject(ObjectOutputStream out) throws IOException {}
   6:     private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { 
   7:         ...
   8:         in.defaultReadObject();
   9:     }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5:   
   6:   private void readObject( ObjectInputStream ois ) throws IOException
   7:   {
   8:     try
   9:     {

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.Serializable;
   4:         ...
   5: 
   6:    private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException
   7:    {
   8:         ...
   9:       ois.defaultReadObject();
  10:       loader = getClass().getClassLoader();

View Full Code Here
   1: 
   2:   private void readObject( ObjectInputStream ois )
   3:     throws ClassNotFoundException, IOException
   4:         ...
   5:     ois.readObject();
   6:     ois.defaultReadObject();
   7:     s = (String)ois.readObject();
   8:   }
   9: }

View Full Code Here
   1: 
   2:     private void readObject(ObjectInputStream in)
   3:                             throws IOException, ClassNotFoundException {
   4:         ...
   5:         in.defaultReadObject();
   6:         try {
   7:             byte b[] = (byte []) in.readObject();
   8:             CertificateFactory cf = 

View Full Code Here

enableResolveObject

protected boolean enableResolveObject(boolean enable)
            throws SecurityException
Enable the stream to allow objects read from the stream to be replaced. When enabled, the resolveObject method is called for every object being deserialized.

If enable is true, and there is a security manager installed, this method first calls the security manager's checkPermission method with the SerializablePermission("enableSubstitution") permission to ensure it's ok to enable the stream to allow objects read from the stream to be replaced.

Parameters:
enable - true for enabling use of resolveObject for every object being deserialized
Returns:
the previous setting before this method was invoked
Throws:
SecurityException - if a security manager exists and its checkPermission method denies enabling the stream to allow objects read from the stream to be replaced.
See Also:
SecurityManager.checkPermission, SerializablePermission

read

public int read()
            throws IOException
Reads a byte of data. This method will block if no input is available.
Specified by:
read in interface ObjectInput
Overrides:
read in interface InputStream
Returns:
the byte read, or -1 if the end of the stream is reached.
Throws:
IOException - If an I/O error has occurred.
Usages and Demos :

View More Examples of read()
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:     private ObjectInputStream m_in = null;
   7: 
   8:         ...
   9:             m_socket.setSoTimeout(m_timeout);
  10:             m_in = new ObjectInputStream(m_socket.getInputStream());
  11:             m_out = new ObjectOutputStream(m_socket.getOutputStream());
  12:         ...
  13:             try {
  14:                 switch (m_in.read()) {

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectStreamException;
   4:         ...
   5:       InputStream is = conn.getInputStream();
   6:       ObjectInputStream ois = new ObjectInputStream(is);
   7:       MarshalledValue mv = (MarshalledValue) ois.readObject();
   8:         ...
   9:       ois.read();
  10:       ois.close();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.Serializable;
   4:         ...
   5: 
   6:     private MessageHeader readMessageHeader(SocketChannel channel, ObjectInputStream objectInput) throws IOException, ClassNotFoundException
   7:     {
   8:         ...
   9:         INode to;
  10:         if(objectInput.read() == 1)
  11:         {
  12:         ...
  13:         {
  14:             if(objectInput.read() == 1)

View Full Code Here
   1: 
   2:     public static SimpleNode readNode(ObjectInputStream in) throws IOException,ParseException {
   3:         int len = in.readInt();
   4:         ...
   5:         ArrayList nodes = new ArrayList();
   6:         int ch = in.read();
   7:         int state = 0;
   8:         ...
   9:                         for (int i = 0; i < len; i++){
  10:                             sb.append((char)in.read());
  11:                         }
  12:         ...
  13:                         sb.setLength(0);
  14:                         in.read();

View Full Code Here
   1: import java.io.NotActiveException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:   private void readObject(ObjectInputStream in)
   7:     throws IOException, NotActiveException, ClassNotFoundException
   8:         ...
   9:     int ch;
  10:     while ((ch = in.read()) != '=')
  11:       {
  12:         ...
  13:     StringBuffer buf = new StringBuffer();
  14:     int ch = in.read();

View Full Code Here

read

public int read(byte[] buf,
                int off,
                int len)
            throws IOException
Reads into an array of bytes. This method will block until some input is available. Consider using java.io.DataInputStream.readFully to read exactly 'length' bytes.
Parameters:
buf - the buffer into which the data is read
off - the start offset of the data
len - the maximum number of bytes read
Returns:
the actual number of bytes read, -1 is returned when the end of the stream is reached.
Throws:
IOException - If an I/O error has occurred.
See Also:
java.io.DataInputStream.readFully(byte[],int,int)
Usages and Demos :

View More Examples of read(byte[] buf,int off,int len)
   1:   }
   2:   private void readObject(java.io.ObjectInputStream in)
   3:     throws IOException, ClassNotFoundException
   4:         ...
   5:   }
   6:   private void readObject(java.io.ObjectInputStream in)
   7:     throws IOException, ClassNotFoundException
   8:         ...
   9:   }
  10:   private void readObject(java.io.ObjectInputStream in)
  11:     throws IOException, ClassNotFoundException
  12:         ...
  13:       {
  14:         len = in.read(buffer, readlen, buffer.length-readlen);

View Full Code Here
   1:   
   2:   private void readObject(ObjectInputStream in)
   3:     throws ClassNotFoundException, IOException
   4:         ...
   5:     
   6:     in.read(_buffer, 0, _length);
   7:   }
   8: 

View Full Code Here
   1: 
   2:           private void readObject(ObjectInputStream oos) throws IOException, ClassNotFoundException {
   3:             hashCode = 100;
   4:         ...
   5: 
   6:     private void readObject(ObjectInputStream oos) throws IOException, ClassNotFoundException {
   7:       bytes = new byte[5];
   8:         ...
   9:       oos.read(bytes, 0, 5);
  10:     }
  11:         ...
  12: 
  13:     private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:         private void readObject(ObjectInputStream in) throws IOException
   7:         {
   8:         ...
   9: 
  10:         private String readObjectV0(ObjectInputStream in, int utfBytes)
  11:                 throws IOException
  12:         ...
  13:                 numRead =
  14:                     in.read(bArray, 2+totalBytesRead, utfBytes-totalBytesRead);

View Full Code Here

readBoolean

public boolean readBoolean()
            throws IOException
Reads in a boolean.
Specified by:
readBoolean in interface DataInput
Returns:
the boolean read.
Throws:
IOException - If other I/O error has occurred.
Usages and Demos :

View More Examples of readBoolean()
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:   public View readView(ObjectInputStream in) throws IOException {
   7:         ...
   8:     return in.readBoolean() ? viewMap.readView(in) : viewSerializer.readView(in);
   9:   }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:   public DockingWindow read(ObjectInputStream in, ReadContext context, ViewReader viewReader) throws IOException {
   7:         ...
   8:     return in.readBoolean() ? getConnectedWindow() : null;
   9:   }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:   protected void read(ObjectInputStream in, RootWindow rootWindow) throws IOException {
   7:         ...
   8:     parentLocation = in.readBoolean() ? LocationDecoder.decode(in, rootWindow) : null;
   9:         ...
  10:     window = in.readBoolean() ?

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.ObjectInputStream;
   3: 
   4:         ...
   5:     private BufferedInputStream bufferedIn = null;
   6:     private ObjectInputStream objIn = null;
   7:     
   8:         ...
   9:         }
  10:         objIn = new ObjectInputStream(bufferedIn);
  11:     }
  12:         ...
  13:         
  14:         return objIn.readBoolean();

View Full Code Here
   1: import java.io.BufferedInputStream;
   2: import java.io.ObjectInputStream;
   3: import java.io.BufferedOutputStream;
   4:         ...
   5:   java.net.Socket sock;
   6:   java.io.ObjectInputStream sockObjIn;
   7:   java.io.ObjectOutputStream sockObjOut;
   8:         ...
   9: public void setSocket(java.net.Socket client) throws java.io.IOException {
  10:   if (client != sock);    setSocket(client, new ObjectInputStream(client.getInputStream()), new ObjectOutputStream(new BufferedOutputStream(client.getOutputStream())));
  11: }
  12:         ...
  13:     int responseType = sockObjIn.readInt();
  14:     if (responseType == 0)  return sockObjIn.readBoolean();

View Full Code Here

readByte

public byte readByte()
            throws IOException
Reads an 8 bit byte.
Specified by:
readByte in interface DataInput
Returns:
the 8 bit byte read.
Throws:
IOException - If other I/O error has occurred.
Usages and Demos :

View More Examples of readByte()
   1: import java.io.InputStream;
   2: import java.io.ObjectInputStream;
   3: 
   4:         ...
   5:     private BufferedInputStream bufferedIn = null;
   6:     private ObjectInputStream objIn = null;
   7:     
   8:         ...
   9:         }
  10:         objIn = new ObjectInputStream(bufferedIn);
  11:     }
  12:         ...
  13:         
  14:         return objIn.readByte();

View Full Code Here
   1:   
   2:   public Geometry read(ObjectInputStream in) throws IOException {
   3:         ...
   4:     final int type = in.readByte();
   5:     switch (type) {
   6:         ...
   7:   
   8:   private Coordinate[] readCoords(ObjectInputStream in) throws IOException {
   9:     final short len = in.readShort();
  10:         ...
  11:   
  12:   private Point readPoint(ObjectInputStream in) throws IOException {

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:         ObjectInputStream in = null;
   7:         LeafNodeEntry entry = null;
   8:         ...
   9:             bybuf.resetData(buf);
  10:             in = new ObjectInputStream(bybuf);
  11: 
  12:         ...
  13:             byte type = in.readByte();

View Full Code Here
   1:             ByteArrayInputStream inp=new ByteArrayInputStream(buf);
   2:             ObjectInputStream in=new ObjectInputStream(inp);
   3: 
   4:         ...
   5:             try {
   6:                 int type=in.readByte();
   7:                 switch(type) {
   8:                     case NULL:
   9:                         return null;

View Full Code Here
   1: import java.io.ObjectInput;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutput;
   4:         ...
   5:     DataInputStream din;
   6:     ObjectInputStream in;
   7:     UID ack;
   8:         ...
   9:     objid = ObjID.read(in);
  10:     byte ack = in.readByte();

View Full Code Here

readChar

public char readChar()
            throws IOException
Reads a 16 bit char.
Specified by:
readChar in interface DataInput
Returns:
the 16 bit char read.
Throws:
IOException - If other I/O error has occurred.
Usages and Demos :

View More Examples of readChar()
   1: 
   2:         ObjectInputStream in = new ObjectInputStream(new
   3:                    FileInputStream("invoice1.txt"));
   4: 
   5:         double price;

View Full Code Here
   1: 
   2:         ObjectInputStream in = new ObjectInputStream(new
   3:                    FileInputStream("invoice1.txt"));
   4: 
   5:         double price;

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.ObjectInputStream;
   3: 
   4:         ...
   5:     private BufferedInputStream bufferedIn = null;
   6:     private ObjectInputStream objIn = null;
   7:     
   8:         ...
   9:         }
  10:         objIn = new ObjectInputStream(bufferedIn);
  11:     }
  12:         ...
  13:         
  14:         return objIn.readChar();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5:     
   6:     public static Paint readPaint(final ObjectInputStream stream)
   7:         throws IOException, ClassNotFoundException {
   8:         ...
   9: 
  10:     public static Stroke readStroke(final ObjectInputStream stream)
  11:         throws IOException, ClassNotFoundException {
  12:         ...
  13:             result = new AttributedString(plainStr);
  14:             char c = stream.readChar();

View Full Code Here

readClassDescriptor

protected ObjectStreamClass readClassDescriptor()
            throws IOException,
                   ClassNotFoundException
Read a class descriptor from the serialization stream. This method is called when the ObjectInputStream expects a class descriptor as the next item in the serialization stream. Subclasses of ObjectInputStream may override this method to read in class descriptors that have been written in non-standard formats (by subclasses of ObjectOutputStream which have overridden the writeClassDescriptor method). By default, this method reads class descriptors according to the format defined in the Object Serialization specification.
Returns:
the class descriptor read
Throws:
IOException - If an I/O error has occurred.
ClassNotFoundException - If the Class of a serialized object used in the class descriptor representation cannot be found
Since:
1.3

readDouble

public double readDouble()
            throws IOException
Reads a 64 bit double.
Specified by:
readDouble in interface DataInput
Returns:
the 64 bit double read.
Throws:
IOException - If other I/O error has occurred.
Usages and Demos :

View More Examples of readDouble()
   1: 
   2:         ObjectInputStream in = new ObjectInputStream(new
   3:                    FileInputStream("invoice1.txt"));
   4:         ...
   5:             while (true) {
   6:                 price = in.readDouble();
   7:                 unit = in.readInt();
   8:                 desc = in.readLine();
   9:                 System.out.println("You've ordered " +

View Full Code Here
   1: 
   2:         ObjectInputStream in = new ObjectInputStream(new
   3:                    FileInputStream("invoice1.txt"));
   4:         ...
   5:             while (true) {
   6:                 price = in.readDouble();
   7:                 unit = in.readInt();
   8:                 desc = in.readLine();
   9:                 System.out.println("You've ordered " +

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:   public Object readObject (final ObjectInputStream in)
   7:           throws IOException, ClassNotFoundException
   8:         ...
   9:   {
  10:     final double x = in.readDouble();
  11:         ...
  12:     final double y = in.readDouble();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:   public Object readObject (final ObjectInputStream in)
   7:           throws IOException, ClassNotFoundException
   8:         ...
   9:   {
  10:     final double w = in.readDouble();
  11:         ...
  12:     final double h = in.readDouble();

View Full Code Here
   1: 
   2:     private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
   3:         in.defaultReadObject();
   4:         ...
   5:         double x1, y1, x2, y2;
   6:         x1 = in.readDouble();
   7:         ...
   8:         y1 = in.readDouble();
   9:         ...
  10:         x2 = in.readDouble();

View Full Code Here

readFields

public ObjectInputStream.GetField readFields()
            throws IOException,
                   ClassNotFoundException
Reads the persistent fields from the stream and makes them available by name.
Returns:
the GetField object representing the persistent fields of the object being deserialized
Throws:
ClassNotFoundException - if the class of a serialized object could not be found.
IOException - if an I/O error occurs.
Since:
1.2
Usages and Demos :

View More Examples of readFields()
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: import java.io.Serializable;
   6: import java.io.ObjectInputStream.GetField;
   7: import java.util.List;
   8:         ...
   9:     @SuppressWarnings("unchecked")
  10:     private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
  11:         ...
  12:         GetField gets = stream.readFields();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3:         ...
   4: import java.io.ObjectInputStream.GetField;
   5: 
   6:         ...
   7: 
   8:     private synchronized void readObject(ObjectInputStream stream) throws IOException,
   9:             ClassNotFoundException {
  10:         ...
  11:         GetField gets = stream.readFields();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3:         ...
   4: import java.io.ObjectInputStream.GetField;
   5: 
   6:         ...
   7: 
   8:     private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
   9:         ...
  10:         GetField gets = stream.readFields();

View Full Code Here

readFloat

public float readFloat()
            throws IOException
Reads a 32 bit float.
Specified by:
readFloat in interface DataInput
Returns:
the 32 bit float read.
Throws:
IOException - If other I/O error has occurred.
Usages and Demos :

View More Examples of readFloat()
   1:               InputStream inputFile = new FileInputStream( "Serialized" );
   2:               ObjectInputStream cin = new ObjectInputStream( inputFile );
   3:               System.out.println( cin.readObject() );
   4:         ...
   5:               System.out.println( cin.readObject() );
   6:               System.out.println( cin.readFloat() );
   7:               System.out.println( cin.readObject() );
   8:           }
   9: }

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.ObjectInputStream;
   3: 
   4:         ...
   5:     private BufferedInputStream bufferedIn = null;
   6:     private ObjectInputStream objIn = null;
   7:     
   8:         ...
   9:         }
  10:         objIn = new ObjectInputStream(bufferedIn);
  11:     }
  12:         ...
  13:         
  14:         return objIn.readFloat();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5:     
   6:     public static Stroke readStroke(ObjectInputStream in) throws IOException, ClassNotFoundException {
   7:         boolean wroteStroke = in.readBoolean();
   8:         ...
   9:                     for (int i = 0; i < dashLength; i++) {
  10:                         dash[i] = in.readFloat();
  11:                     }
  12:         ...
  13:                 
  14:                 float lineWidth = in.readFloat();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:   private void readObject(ObjectInputStream s)
   7:     throws IOException, ClassNotFoundException
   8:         ...
   9: 
  10:     map = init(s.readInt(), s.readFloat());
  11:     for (int size = s.readInt(); size > 0; size--)

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:   protected DockingWindow oldRead(ObjectInputStream in, ReadContext context) throws IOException {
   7:     splitPane.setHorizontal(in.readBoolean());
   8:         ...
   9:     splitPane.setDividerLocation(in.readFloat());
  10:     DockingWindow leftWindow = WindowDecoder.decodeWindow(in, context);
  11:         ...
  12: 
  13:   protected DockingWindow newRead(ObjectInputStream in, ReadContext context, ViewReader viewReader) throws IOException {

View Full Code Here

readFully

public void readFully(byte[] buf)
            throws IOException
Reads bytes, blocking until all bytes are read.
Parameters:
buf - the buffer into which the data is read
Throws:
IOException - If other I/O error has occurred.
Usages and Demos :

View More Examples of readFully(byte[] buf)
   1: 
   2:   private void readObject(java.io.ObjectInputStream stream) throws IOException,
   3:       ClassNotFoundException {
   4:         ...
   5:         byte[] encoded = new byte[certLength];
   6:         stream.readFully(encoded);
   7:         ByteArrayInputStream bis = new ByteArrayInputStream(encoded);
   8:         ...
   9:     byte[] keyEncoded = new byte[keyLength];
  10:     stream.readFully(keyEncoded);
  11:     try {

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5:     {
   6:         ObjectInputStream oin = new ObjectInputStream(in);
   7: 
   8:         ...
   9:         byte[] asig = new byte[6];
  10:         oin.readFully(asig);
  11:         String ssig = new String(asig);

View Full Code Here
   1: 
   2:   private void readObject(java.io.ObjectInputStream stream) throws IOException,
   3:       ClassNotFoundException {
   4:         ...
   5:         byte[] encoded = new byte[certLength];
   6:         stream.readFully(encoded);
   7:         ByteArrayInputStream bis = new ByteArrayInputStream(encoded);
   8:         ...
   9:     byte[] keyEncoded = new byte[keyLength];
  10:     stream.readFully(keyEncoded);
  11:     try {

View Full Code Here
   1:     private ObjectOutputStream oos;
   2:     private ObjectInputStream ois;
   3:     private String host;
   4:         ...
   5:             oos = new ObjectOutputStream(hostSocket.getOutputStream());
   6:             ois = new ObjectInputStream(hostSocket.getInputStream());
   7:         
   8:         ...
   9:             byte[] byteCode = new byte[ois.readInt()];
  10:             ois.readFully(byteCode);
  11:             return byteCode;

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:   private void readObject(ObjectInputStream in) throws IOException
   7:   {
   8:         ...
   9:     byte[] seed = new byte[SEED_FILE_SIZE];
  10:     in.readFully(seed);
  11:     generator.addRandomBytes(seed);

View Full Code Here

readFully

public void readFully(byte[] buf,
                      int off,
                      int len)
            throws IOException
Reads bytes, blocking until all bytes are read.
Parameters:
buf - the buffer into which the data is read
off - the start offset of the data
len - the maximum number of bytes to read
Throws:
IOException - If other I/O error has occurred.
Usages and Demos :

View More Examples of readFully(byte[] buf,int off,int len)
   1: 
   2:   private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
   3:     ois.defaultReadObject();
   4:         ...
   5:     payload = new byte[ois.readInt()];
   6:     ois.readFully(payload, 0, payload.length);
   7:   }
   8: 
   9:   public void serialize(OutputBuffer buf) throws IOException {

View Full Code Here
   1: 
   2:   private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
   3:     ois.defaultReadObject();
   4:         ...
   5:     payload = new byte[ois.readInt()];
   6:     ois.readFully(payload, 0, payload.length);
   7:   }
   8: }

View Full Code Here
   1: 
   2:   private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
   3:     ois.defaultReadObject();
   4:         ...
   5:     objectHash = new byte[objectHashLength];
   6:     ois.readFully(objectHash, 0, objectHashLength);
   7:     byte[] fragmentHashField = new byte[fragmentHashLength * fragmentHashSubLength];
   8:         ...
   9:     ois.readFully(fragmentHashField, 0, fragmentHashLength * fragmentHashSubLength);
  10:     fragmentHash = new byte[fragmentHashLength][fragmentHashSubLength];
  11:         ...
  12:     signature = new byte[signatureLength];
  13:     ois.readFully(signature, 0, signatureLength);

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5:   
   6:   private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException
   7:   {
   8:         ...
   9:     this.gap.prepareAdd(0, size);
  10:     in.readFully(this.gap.bytes, 0, size);
  11:   }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5:   
   6:   private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException
   7:   {
   8:         ...
   9:     this.lowWaterMark = this.shrink ? chooseLowWaterMark(this.size, this.growFactor) : 0;
  10:     in.readFully(elements, 0, this.size);
  11:   }

View Full Code Here

readInt

public int readInt()
            throws IOException
Reads a 32 bit int.
Specified by:
readInt in interface DataInput
Returns:
the 32 bit integer read.
Throws:
IOException - If other I/O error has occurred.
Usages and Demos :

View More Examples of readInt()
   1:     }
   2:     private void readObject(java.io.ObjectInputStream in)
   3:         throws IOException, ClassNotFoundException {
   4:         ...
   5:     i = in.readInt();
   6:     }
   7:         ...
   8:         throws IOException, ClassNotFoundException {
   9:     in.readInt();
  10:     }

View Full Code Here
   1: import java.io.ObjectOutputStream;
   2: import java.io.ObjectInputStream;
   3: import java.net.Socket;
   4:         ...
   5:        outStream.flush();
   6:        ObjectInputStream inStream = 
   7:         ...
   8:            new ObjectInputStream(socket.getInputStream());
   9:         ...
  10:        return inStream.readInt();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:   protected Object readViewId(ObjectInputStream in) throws IOException {
   7:         ...
   8:     return new Integer(in.readInt());
   9:   }

View Full Code Here
   1:     {
   2:         return in.readInt();
   3:     }
   4:         ...
   5:         out = new ObjectOutputStream(socket.getOutputStream());
   6:         in = new ObjectInputStream(socket.getInputStream());
   7:     }
   8:         ...
   9:         int j;
  10:         if((j = in.readInt()) != i)
  11:             throw new Exception(s + "(Recieved " + j + " instead of " + i + ")");
  12:         ...
  13:     Socket socket;
  14:     ObjectInputStream in;

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:     private void readObject(ObjectInputStream ois)
   7:       throws IOException
   8:         ...
   9:     {
  10:       serializationTime = ois.readInt();
  11:         ...
  12:       ois.readInt();

View Full Code Here

readLong

public long readLong()
            throws IOException
Reads a 64 bit long.
Specified by:
readLong in interface DataInput
Returns:
the read 64 bit long.
Throws:
IOException - If other I/O error has occurred.
Usages and Demos :

View More Examples of readLong()
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
   7:         ...
   8:       date = new Date(in.readLong());
   9:       buildInternationalStrings();

View Full Code Here
   1: 
   2:    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
   3:         ...
   4:       date = new Date(in.readLong());
   5:    }
   6: 
   7: }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5:     }
   6:     private void readObject(ObjectInputStream in) throws IOException,
   7:             ClassNotFoundException
   8:         ...
   9: 
  10:         id = new Long(in.readLong());
  11:         contextName = in.readUTF();
  12:         ...
  13:         if (dateSet == 1)
  14:             lastDeployDate = new Date(in.readLong());

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.ObjectInputStream;
   3: 
   4:         ...
   5:     private BufferedInputStream bufferedIn = null;
   6:     private ObjectInputStream objIn = null;
   7:     
   8:         ...
   9:         }
  10:         objIn = new ObjectInputStream(bufferedIn);
  11:     }
  12:         ...
  13:         
  14:         return objIn.readLong();

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:         ObjectInputStream in = null;
   7:         LeafNodeEntry entry = null;
   8:         ...
   9:             bybuf.resetData(buf);
  10:             in = new ObjectInputStream(bybuf);
  11: 
  12:         ...
  13:         case LONG:
  14:             return new Long(in.readLong());

View Full Code Here

readObject

public final Object readObject()
            throws IOException,
                   ClassNotFoundException
Read an object from the ObjectInputStream. The class of the object, the signature of the class, and the values of the non-transient and non-static fields of the class and all of its supertypes are read. Default deserializing for a class can be overriden using the writeObject and readObject methods. Objects referenced by this object are read transitively so that a complete equivalent graph of objects is reconstructed by readObject.

The root object is completely restored when all of its fields and the objects it references are completely restored. At this point the object validation callbacks are executed in order based on their registered priorities. The callbacks are registered by objects (in the readObject special methods) as they are individually restored.

Exceptions are thrown for problems with the InputStream and for classes that should not be deserialized. All exceptions are fatal to the InputStream and leave it in an indeterminate state; it is up to the caller to ignore or recover the stream state.

Specified by:
readObject in interface ObjectInput
Throws:
ClassNotFoundException - Class of a serialized object cannot be found.
IOException - Any of the usual Input/Output related exceptions.
Usages and Demos :

View More Examples of readObject()
   1: 
   2:   private void readObject( ObjectInputStream ois )
   3:     throws ClassNotFoundException, IOException
   4:         ...
   5:   {
   6:     ois.readObject();
   7:     ois.defaultReadObject();
   8:         ...
   9:     s = (String)ois.readObject();
  10:   }

View Full Code Here
   1: import java.io.ObjectOutputStream;
   2: import java.io.ObjectInputStream;
   3: 
   4:         ...
   5:     public Object deserialize(InputStream input) throws Exception {
   6:         ObjectInputStream objectInputStream = new ObjectInputStream(input);
   7:         ...
   8:         return objectInputStream.readObject();
   9:     }

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.ObjectInputStream;
   3: import java.util.Map;
   4:         ...
   5:         if(stream == null) return null;
   6:         ObjectInputStream objectStream = null;
   7:         try { 
   8:         ...
   9:             objectStream = new ObjectInputStream(stream);
  10:         ...
  11:             return objectStream.readObject();

View Full Code Here
   1: {
   2:   private ObjectInputStream in_;
   3: 
   4:         ...
   5:       _in=new BufferedInputStream(_in,BUFFER_SIZE);
   6:     in_=new ObjectInputStream(_in);
   7:   }
   8:         ...
   9:   {
  10:     return in_.readObject();
  11:   }

View Full Code Here
   1: import java.io.InputStream;
   2: import java.io.ObjectInputStream;
   3: 
   4:         ...
   5:     {
   6:     ObjectInputStream ois = new ObjectInputStream(is);
   7:         ...
   8:     return ois.readObject();
   9:     }

View Full Code Here

readObjectOverride

protected Object readObjectOverride()
            throws IOException,
                   ClassNotFoundException
This method is called by trusted subclasses of ObjectOutputStream that constructed ObjectOutputStream using the protected no-arg constructor. The subclass is expected to provide an override method with the modifier "final".
Returns:
the Object read from the stream.
Throws:
ClassNotFoundException - Class definition of a serialized object cannot be found.
IOException - if I/O errors occurred while reading from the underlying stream
Since:
1.2

readShort

public short readShort()
            throws IOException
Reads a 16 bit short.
Specified by:
readShort in interface DataInput
Returns:
the 16 bit short read.
Throws:
IOException - If other I/O error has occurred.
Usages and Demos :

View More Examples of readShort()
   1:     
   2:     private void readObject(ObjectInputStream in) throws Exception
   3:     {
   4:         ...
   5:     short version = in.readShort();
   6:     switch (version)
   7:         {
   8:         case 0x0001:

View Full Code Here
   1:     
   2:     private void readObject(ObjectInputStream in) throws IOException
   3:     {
   4:         ...
   5:     short version = in.readShort();
   6:     switch (version)
   7:         {
   8:         case 0x0001:

View Full Code Here
   1:     
   2:     private void readObject(ObjectInputStream in) throws Exception
   3:     {
   4:         ...
   5:     short version = in.readShort();
   6:     switch (version)
   7:         {
   8:         case 0x0001:

View Full Code Here
   1:     
   2:     private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
   3:     {
   4:         ...
   5:     short version = in.readShort();
   6:     switch (version)
   7:         {
   8:         case 0x0001:

View Full Code Here
   1:     
   2:     private void readObject(ObjectInputStream in) throws IOException
   3:     {
   4:         ...
   5:     short version = in.readShort();
   6:     switch (version)
   7:         {
   8:         case 0x0001:

View Full Code Here

readStreamHeader

protected void readStreamHeader()
            throws IOException,
                   StreamCorruptedException
The readStreamHeader method is provided to allow subclasses to read and verify their own stream headers. It reads and verifies the magic number and version number.
Throws:
IOException - if there are I/O errors while reading from the underlying InputStream
StreamCorruptedException - if control information in the stream is inconsistent

readUTF

public String readUTF()
            throws IOException
Reads a String in modified UTF-8 format.
Specified by:
readUTF in interface DataInput
Returns:
the String.
Throws:
IOException - if there are I/O errors while reading from the underlying InputStream
Usages and Demos :

View More Examples of readUTF()
   1:               InputStream inputFile = new FileInputStream( "Serialized" );
   2:               ObjectInputStream cin = new ObjectInputStream( inputFile );
   3:               System.out.println( cin.readObject() );
   4:         ...
   5:               System.out.println( cin.readUTF() );
   6:               System.out.println( cin.readObject() );
   7:               System.out.println( cin.readFloat() );
   8:               System.out.println( cin.readObject() );

View Full Code Here
   1:     {
   2:         return in.readUTF();
   3:     }
   4:         ...
   5:         out = new ObjectOutputStream(socket.getOutputStream());
   6:         in = new ObjectInputStream(socket.getInputStream());
   7:     }
   8:         ...
   9:     Socket socket;
  10:     ObjectInputStream in;
  11:     ObjectOutputStream out;

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:   protected Object readViewId(ObjectInputStream in) throws IOException {
   7:         ...
   8:     return in.readUTF();
   9:   }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:   private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException  
   7:   {
   8:         ...
   9:     in.defaultReadObject();
  10:     _name = in.readUTF();
  11:   }

View Full Code Here
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:   private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
   7:   {
   8:         ...
   9:     in.defaultReadObject();
  10:     _name = in.readUTF();
  11:   }

View Full Code Here

readUnshared

public Object readUnshared()
            throws IOException,
                   ClassNotFoundException
Reads an "unshared" object from the ObjectInputStream. This method is identical to readObject, except that it prevents subsequent calls to readObject and readUnshared from returning additional references to the deserialized instance obtained via this call. Specifically:
  • If readUnshared is called to deserialize a back-reference (the stream representation of an object which has been written previously to the stream), an ObjectStreamException will be thrown.
  • If readUnshared returns successfully, then any subsequent attempts to deserialize back-references to the stream handle deserialized by readUnshared will cause an ObjectStreamException to be thrown.
Deserializing an object via readUnshared invalidates the stream handle associated with the returned object. Note that this in itself does not always guarantee that the reference returned by readUnshared is unique; the deserialized object may define a readResolve method which returns an object visible to other parties, or readUnshared may return a Class object or enum constant obtainable elsewhere in the stream or through external means.

However, for objects which are not enum constants or instances of java.lang.Class and do not define readResolve methods, readUnshared guarantees that the returned object reference is unique and cannot be obtained a second time from the ObjectInputStream that created it, even if the underlying data stream has been manipulated. This guarantee applies only to the base-level object returned by readUnshared, and not to any transitively referenced sub-objects in the returned object graph.

ObjectInputStream subclasses which override this method can only be constructed in security contexts possessing the "enableSubclassImplementation" SerializablePermission; any attempt to instantiate such a subclass without this permission will cause a SecurityException to be thrown.

Returns:
reference to deserialized object
Throws:
ClassNotFoundException - if class of an object to deserialize cannot be found
IOException - if an I/O error occurs during deserialization

readUnsignedByte

public int readUnsignedByte()
            throws IOException
Reads an unsigned 8 bit byte.
Specified by:
readUnsignedByte in interface DataInput
Returns:
the 8 bit byte read.
Throws:
IOException - If other I/O error has occurred.
Usages and Demos :

View More Examples of readUnsignedByte()
   1: import java.io.ObjectInput;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutput;
   4:         ...
   5:     DataInputStream din;
   6:     ObjectInputStream in;
   7:     UID ack;
   8:         ...
   9:         
  10:         if ((returncode = din.readUnsignedByte()) != MESSAGE_CALL_ACK) {
  11:             conn.disconnect();
  12:         ...
  13: 
  14:         returncode = in.readUnsignedByte();

View Full Code Here

readUnsignedShort

public int readUnsignedShort()
            throws IOException
Reads an unsigned 16 bit short.
Specified by:
readUnsignedShort in interface DataInput
Returns:
the 16 bit short read.
Throws:
IOException - If other I/O error has occurred.
Usages and Demos :

View More Examples of readUnsignedShort()
   1: import java.io.IOException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectOutputStream;
   4:         ...
   5: 
   6:         private void readObject(ObjectInputStream in) throws IOException
   7:         {
   8:         ...
   9: 
  10:                 int utfBytes = in.readUnsignedShort();
  11: 
  12:         ...
  13:                 {
  14:                     majorVersionNum = in.readUnsignedShort();

View Full Code Here

registerValidation

public void registerValidation(ObjectInputValidation obj,
                               int prio)
            throws NotActiveException,
                   InvalidObjectException
Register an object to be validated before the graph is returned. While similar to resolveObject these validations are called after the entire graph has been reconstituted. Typically, a readObject method will register the object with the stream so that when all of the objects are restored a final set of validations can be performed.
Parameters:
obj - the object to receive the validation callback.
prio - controls the order of callbacks;zero is a good default. Use higher numbers to be called back earlier, lower numbers for later callbacks. Within a priority, callbacks are processed in no particular order.
Throws:
NotActiveException - The stream is not currently reading objects so it is invalid to register a callback.
InvalidObjectException - The validation object is null.
Usages and Demos :

View More Examples of registerValidation(ObjectInputValidation obj,int prio)
   1: import java.io.InvalidObjectException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectInputValidation;
   4:         ...
   5: 
   6:     private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
   7:         stream.defaultReadObject();
   8:     }

View Full Code Here
   1: import java.io.InvalidObjectException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectInputValidation;
   4:         ...
   5: 
   6:     private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
   7:         stream.defaultReadObject();
   8:         this.listenerList = new EventListenerList();
   9:     }

View Full Code Here
   1: import java.io.InvalidObjectException;
   2: import java.io.ObjectInputStream;
   3: import java.io.ObjectInputValidation;
   4:         ...
   5: 
   6:     private void readObject(ObjectInputStream stream) 
   7:         throws IOException, ClassNotFoundException {
   8:         stream.defaultReadObject();
   9:         this.listenerList = new EventListenerList();

View Full Code Here

resolveClass

protected Class resolveClass(ObjectStreamClass desc)
            throws IOException,
                   ClassNotFoundException
Load the local class equivalent of the specified stream class description. Subclasses may implement this method to allow classes to be fetched from an alternate source.

The corresponding method in ObjectOutputStream is annotateClass. This method will be invoked only once for each unique class in the stream. This method can be implemented by subclasses to use an alternate loading mechanism but must return a Class object. Once returned, the serialVersionUID of the class is compared to the serialVersionUID of the serialized class. If there is a mismatch, the deserialization fails and an exception is raised.

By default the class name is resolved relative to the class that called readObject.

Parameters:
desc - an instance of class ObjectStreamClass
Returns:
a Class object corresponding to desc
Throws:
IOException - any of the usual input/output exceptions
ClassNotFoundException - if class of a serialized object cannot be found

resolveObject

protected Object resolveObject(Object obj)
            throws IOException
This method will allow trusted subclasses of ObjectInputStream to substitute one object for another during deserialization. Replacing objects is disabled until enableResolveObject is called. The enableResolveObject method checks that the stream requesting to resolve object can be trusted. Every reference to serializable objects is passed to resolveObject. To insure that the private state of objects is not unintentionally exposed only trusted streams may use resolveObject.

This method is called after an object has been read but before it is returned from readObject. The default resolveObject method just returns the same object.

When a subclass is replacing objects it must insure that the substituted object is compatible with every field where the reference will be stored. Objects whose type is not a subclass of the type of the field or array element abort the serialization by raising an exception and the object is not be stored.

This method is called only once when each object is first encountered. All subsequent references to the object will be redirected to the new object.

Parameters:
obj - object to be substituted
Returns:
the substituted object
Throws:
IOException - Any of the usual Input/Output exceptions.

resolveProxyClass

protected Class resolveProxyClass(String[] interfaces)
            throws IOException,
                   ClassNotFoundException
Returns a proxy class that implements the interfaces named in a proxy class descriptor; subclasses may implement this method to read custom data from the stream along with the descriptors for dynamic proxy classes, allowing them to use an alternate loading mechanism for the interfaces and the proxy class.

This method is called exactly once for each unique proxy class descriptor in the stream.

The corresponding method in ObjectOutputStream is annotateProxyClass. For a given subclass of ObjectInputStream that overrides this method, the annotateProxyClass method in the corresponding subclass of ObjectOutputStream must write any data or objects read by this method.

The default implementation of this method in ObjectInputStream returns the result of calling Proxy.getProxyClass with the list of Class objects for the interfaces that are named in the interfaces parameter. The Class object for each interface name i is the value returned by calling

     Class.forName(i, false, loader)
 
where loader is that of the first non-null class loader up the execution stack, or null if no non-null class loaders are on the stack (the same class loader choice used by the resolveClass method). Unless any of the resolved interfaces are non-public, this same value of loader is also the class loader passed to Proxy.getProxyClass; if non-public interfaces are present, their class loader is passed instead (if more than one non-public interface class loader is encountered, an IllegalAccessError is thrown). If Proxy.getProxyClass throws an IllegalArgumentException, resolveProxyClass will throw a ClassNotFoundException containing the IllegalArgumentException.
Parameters:
interfaces - the list of interface names that were deserialized in the proxy class descriptor
Returns:
a proxy class for the specified interfaces
Throws:
IOException - any exception thrown by the underlying InputStream
ClassNotFoundException - if the proxy class or any of the named interfaces could not be found
Since:
1.3
See Also:
ObjectOutputStream.annotateProxyClass(Class)

skipBytes

public int skipBytes(int len)
            throws IOException
Skips bytes, block until all bytes are skipped.
Specified by:
skipBytes in interface DataInput
Parameters:
len - the number of bytes to be skipped
Returns:
the actual number of bytes skipped.
Throws:
IOException - If other I/O error has occurred.