📄 objectinputstream.html
字号:
<TD><CODE><B><A HREF="../../java/io/ObjectInputStream.html#resolveObject(java.lang.Object)">resolveObject</A></B>(<A HREF="../../java/lang/Object.html">Object</A> obj)</CODE><BR> This method will allow trusted subclasses of ObjectInputStream to substitute one object for another during deserialization.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>protected <A HREF="../../java/lang/Class.html">Class</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/ObjectInputStream.html#resolveProxyClass(java.lang.String[])">resolveProxyClass</A></B>(<A HREF="../../java/lang/String.html">String</A>[] interfaces)</CODE><BR> 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.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/io/ObjectInputStream.html#skipBytes(int)">skipBytes</A></B>(int len)</CODE><BR> Skips bytes, block until all bytes are skipped.</TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.io.InputStream"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class java.io.<A HREF="../../java/io/InputStream.html">InputStream</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/io/InputStream.html#mark(int)">mark</A>, <A HREF="../../java/io/InputStream.html#markSupported()">markSupported</A>, <A HREF="../../java/io/InputStream.html#read(byte[])">read</A>, <A HREF="../../java/io/InputStream.html#reset()">reset</A>, <A HREF="../../java/io/InputStream.html#skip(long)">skip</A></CODE></TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from class java.lang.<A HREF="../../java/lang/Object.html">Object</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/lang/Object.html#clone()">clone</A>, <A HREF="../../java/lang/Object.html#equals(java.lang.Object)">equals</A>, <A HREF="../../java/lang/Object.html#finalize()">finalize</A>, <A HREF="../../java/lang/Object.html#getClass()">getClass</A>, <A HREF="../../java/lang/Object.html#hashCode()">hashCode</A>, <A HREF="../../java/lang/Object.html#notify()">notify</A>, <A HREF="../../java/lang/Object.html#notifyAll()">notifyAll</A>, <A HREF="../../java/lang/Object.html#toString()">toString</A>, <A HREF="../../java/lang/Object.html#wait()">wait</A>, <A HREF="../../java/lang/Object.html#wait(long)">wait</A>, <A HREF="../../java/lang/Object.html#wait(long, int)">wait</A></CODE></TD></TR></TABLE> <A NAME="methods_inherited_from_class_java.io.ObjectInput"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Methods inherited from interface java.io.<A HREF="../../java/io/ObjectInput.html">ObjectInput</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/io/ObjectInput.html#read(byte[])">read</A>, <A HREF="../../java/io/ObjectInput.html#skip(long)">skip</A></CODE></TD></TR></TABLE> <P><!-- ============ FIELD DETAIL =========== --><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TD></TR></TABLE><A NAME="ObjectInputStream(java.io.InputStream)"><!-- --></A><H3>ObjectInputStream</H3><PRE>public <B>ObjectInputStream</B>(<A HREF="../../java/io/InputStream.html">InputStream</A> in) throws <A HREF="../../java/io/IOException.html">IOException</A>, <A HREF="../../java/io/StreamCorruptedException.html">StreamCorruptedException</A></PRE><DL><DD>Create an ObjectInputStream that reads from the specified InputStream. The stream header containing the magic number and version number are read from the stream and verified. This method will block until the corresponding ObjectOutputStream has written and flushed the header.<DD><DL><DT><B>Parameters:</B><DD><CODE>in</CODE> - the underlying <code>InputStream</code> from which to read<DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/StreamCorruptedException.html">StreamCorruptedException</A></CODE> - The version or magic number are incorrect.<DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - An exception occurred in the underlying stream.</DL></DD></DL><HR><A NAME="ObjectInputStream()"><!-- --></A><H3>ObjectInputStream</H3><PRE>protected <B>ObjectInputStream</B>() throws <A HREF="../../java/io/IOException.html">IOException</A>, <A HREF="../../java/lang/SecurityException.html">SecurityException</A></PRE><DL><DD>Provide a way for subclasses that are completely reimplementing ObjectInputStream to not have to allocate private data just used by this implementation of ObjectInputStream. <p>If there is a security manager installed, this method first calls the security manager's <code>checkPermission</code> method with the <code>SerializablePermission("enableSubclassImplementation")</code> permission to ensure it's ok to enable subclassing.<DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - Thrown if not called by a subclass.<DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if a security manager exists and its <code>checkPermission</code> method denies enabling subclassing.<DT><B>See Also: </B><DD><A HREF="../../java/lang/SecurityManager.html#checkPermission(java.security.Permission)"><CODE>SecurityManager.checkPermission(java.security.Permission)</CODE></A>, <A HREF="../../java/io/SerializablePermission.html"><CODE>SerializablePermission</CODE></A></DL></DD></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="readObject()"><!-- --></A><H3>readObject</H3><PRE>public final <A HREF="../../java/lang/Object.html">Object</A> <B>readObject</B>() throws <A HREF="../../java/io/OptionalDataException.html">OptionalDataException</A>, <A HREF="../../java/lang/ClassNotFoundException.html">ClassNotFoundException</A>, <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>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. <p> The root object is completly 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.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/io/ObjectInput.html#readObject()">readObject</A></CODE> in interface <CODE><A HREF="../../java/io/ObjectInput.html">ObjectInput</A></CODE></DL></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassNotFoundException.html">ClassNotFoundException</A></CODE> - Class of a serialized object cannot be found.<DD><CODE><A HREF="../../java/io/InvalidClassException.html">InvalidClassException</A></CODE> - Something is wrong with a class used by serialization.<DD><CODE><A HREF="../../java/io/StreamCorruptedException.html">StreamCorruptedException</A></CODE> - Control information in the stream is inconsistent.<DD><CODE><A HREF="../../java/io/OptionalDataException.html">OptionalDataException</A></CODE> - Primitive data was found in the stream instead of objects.<DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - Any of the usual Input/Output related exceptions.</DL></DD></DL><HR><A NAME="readObjectOverride()"><!-- --></A><H3>readObjectOverride</H3><PRE>protected <A HREF="../../java/lang/Object.html">Object</A> <B>readObjectOverride</B>() throws <A HREF="../../java/io/OptionalDataException.html">OptionalDataException</A>, <A HREF="../../java/lang/ClassNotFoundException.html">ClassNotFoundException</A>, <A HREF="../../java/io/IOException.html">IOException</A></PRE><DL><DD>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".<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the Object read from the stream.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassNotFoundException.html">ClassNotFoundException</A></CODE> - Class definition of a serialized object cannot be found.<DD><CODE><A HREF="../../java/io/OptionalDataException.html">OptionalDataException</A></CODE> - Primitive data was found in the stream instead of objects.<DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if I/O errors occurred while reading from the underlying stream<DT><B>Since: </B><DD>1.2</DD><DT><B>See Also: </B><DD><A HREF="../../java/io/ObjectInputStream.html#ObjectInputStream()"><CODE>ObjectInputStream()</CODE></A>, <A HREF="../../java/io/ObjectInputStream.html#readObject()"><CODE>readObject()</CODE></A></DL></DD></DL><HR><A NAME="defaultReadObject()"><!-- --></A><H3>defaultReadObject</H3><PRE>public void <B>defaultReadObject</B>() throws <A HREF="../../java/io/IOException.html">IOException</A>, <A HREF="../../java/lang/ClassNotFoundException.html">ClassNotFoundException</A>, <A HREF="../../java/io/NotActiveException.html">NotActiveException</A></PRE><DL><DD>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.<DD><DL></DL></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassNotFoundException.html">ClassNotFoundException</A></CODE> - if the class of a serialized object could not be found.<DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.<DD><CODE><A HREF="../../java/io/NotActiveException.html">NotActiveException</A></CODE> - if the stream is not currently reading objects.</DL></DD></DL><HR><A NAME="readFields()"><!-- --></A><H3>readFields</H3><PRE>public <A HREF="../../java/io/ObjectInputStream.GetField.html">ObjectInputStream.GetField</A> <B>readFields</B>() throws <A HREF="../../java/io/IOException.html">IOException</A>, <A HREF="../../java/lang/ClassNotFoundException.html">ClassNotFoundException</A>, <A HREF="../../java/io/NotActiveException.html">NotActiveException</A></PRE><DL><DD>Reads the persistent fields from the stream and makes them available by name.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>the <code>GetField</code> object representing the persistent fields of the object being deserialized<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassNotFoundException.html">ClassNotFoundException</A></CODE> - if the class of a serialized object could not be found.<DD><CODE><A HREF="../../java/io/IOException.html">IOException</A></CODE> - if an I/O error occurs.<DD><CODE><A HREF="../../java/io/NotActiveException.html">NotActiveException</A></CODE> - if the stream is not currently reading objects.<DT><B>Since: </B><DD>1.2</DD></DL></DD></DL><HR><A NAME="registerValidation(java.io.ObjectInputValidation, int)"><!-- --></A><H3>registerValidation</H3><PRE>public void <B>registerValidation</B>(<A HREF="../../java/io/ObjectInputValidation.html">ObjectInputValidation</A> obj, int prio) throws <A HREF="../../java/io/NotActiveException.html">NotActiveException</A>, <A HREF="../../java/io/InvalidObjectException.html">InvalidObjectException</A></PRE><DL><DD>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.<DD><DL></DL></DD>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -