Clase Java.io.ObjectInputStream en Java | conjunto 2

Clase Java.io.ObjectInputStream en Java | Conjunto 1  
Nota: 
los códigos Java mencionados en este artículo no se ejecutarán en el IDE en línea ya que el archivo utilizado en el código no existe en línea. Entonces, para verificar el funcionamiento de los códigos, puede copiarlos en su Sistema y ejecutarlos allí. 
Más métodos de la clase ObjectInputStream: 
 

  • defaultReadObject() : java.io.ObjectInputStream.defaultReadObject() lee el campo no estático de la clase actual del Input Stream. Usamos el método readObject() de la clase serializada para llamar a este método. 
    Sintaxis:
public void defaultReadObject()
Parameters : 
-----------
Return : 
void
Exception :
-> IOException : in case of any IO error occurs.
-> ClassNotFoundException : if the class of Object(being serialized) is not found
-> NotActiveException : if the Stream is not reading.
  • readObject() : java.io.ObjectInputStream.readObject() lee un objeto de la clase serializada. Este método se utiliza para llamar al objeto de lectura predeterminado. Si la clase se deserializa de forma predeterminada, se puede anular mediante los métodos readObject y writeObject. 
    Sintaxis:
public void defaultReadObject()
Parameters : 
public final Object readObject()
Return : 
void
Exception :
-> IOException : in case of any IO error occurs.
-> ClassNotFoundException : if the class of Object(being serialized) is not found
-> OptionalDataException : if instead of object, primitive data is found.
-> InvalidClassException : is there is something wrong with serialized class
  • disponible() : java.io.ObjectInputStream.disponible() dice el no. de bytes de los que se pueden leer sin ser bloqueados 
    Sintaxis:
public int available()
Parameters : 
-----------
Return : 
no. of bytes of that can be read without being blocked
Exception :
-> IOException : in case of any IO error occurs.
  • close(): java.io.ObjectInputStream.close() cierra el flujo de entrada y libera todos los recursos asignados al flujo 
    Sintaxis:
public void close()
Parameters : 
-----------
Return : 
void
Exception :
-> IOException : in case of any IO error occurs.
  • readShort() : java.io.ObjectInputStream.readShort() lee 16 bits cortos. 
    Sintaxis:
public short readShort()
Parameters : 
public final Object readObject()
Return : 
reads 16 bit short.
Exception :
-> IOException : in case of any IO error occurs.
-> EOFException : if End of stream is reached
  • readUTF() : java.io.ObjectInputStream.readUTF() lee String en formato UTF-8 (Unicode Transformation Format) modificado. UTF -8 significa que utiliza bloques de 8 bits para representar un carácter. 
    Sintaxis:
public String readUTF()
Parameters : 
public final Object readObject()
Return : 
reads String in modified UTF-8 (Unicode Transformation Format) format
Exception :
-> IOException : in case of any IO error occurs.
  • skipBytes(int maxlen) : java.io.ObjectInputStream.skipBytes(int maxlen) salta ‘maxlen’ no. de bytes durante la lectura. 
    Sintaxis:
public int skipBytes(int maxlen)
Parameters : 
maxlen : max. no. of bytes to be skipped
Return : 
no. of bytes to be skipped
Exception :
-> IOException : in case of any IO error occurs.
  • readFully(byte[] destino) : java.io.ObjectInputStream.readFully(byte[] destino) lee todos los bytes desde el origen hasta la array de destino. 
    Sintaxis:
public void readFully(byte[] destination)
Parameters : 
destination : the buffer in which the data is to be read
Return : 
returns the 32 bit float read
Exception :
-> IOException : in case of any IO error occurs.
-> EOFException : if End of stream is reached
  • readFully(byte[] destino, int offset, int maxlen) : java.io.ObjectInputStream.readFully(byte[] destino, int offset, int maxlen) lee algunos bytes (desde el desplazamiento hasta la posición maxlen) desde el origen hasta el destino array 
    Sintaxis:
public void readFully(byte[] destination, int offset, int maxlen)
Parameters : 
destination : the buffer in which the data is to be read
offset : starting position of the buffer
maxlen : max no. of bytes to be read
Return : 
void
Exception :
-> IOException : in case of any IO error occurs.
-> EOFException : if End of stream is reached
  • readFields() : java.io.ObjectInputStream.readFields() lee el campo constante del flujo de entrada e indica el nombre. 
    Sintaxis:
public ObjectInputStream.GetField readFields()
Parameters : 
-------
Return : 
GetField object reading the constant fields
Exception :
-> IOException : in case of any IO error occurs.
-> ClassNotFoundException : if class of serialized object is not found
  • resolveClass() : java.io.ObjectInputStream.resolveClass(ObjectStreamClass INS_class) carga una clase de instancia en la clase de flujo especificada en lugar de ella. 
    Sintaxis:
protected Class resolveClass(ObjectStreamClass desc)

 : means that the class object can be of any type, it is to be specified by the coder.
Parameters : 
INS_class : instance of the specified Stream Class
Return : 
Class Object equivalent to the Specified Stream Class
Exception :
-> IO Exception : if any IO exception occurs
-> ClassNotFoundException : if the argumented class is not available.
  • registerValidation() : java.io.ObjectInputStream.registerValidation(ObjectInputValidation object, int order) registra el objeto para validarlo. 
    Sintaxis:
public void registerValidation(ObjectInputValidation object, int order)
Parameters : 
-------
Return : 
object : object to be validated 
order : Controls the order of callback. These are processed in no particular order
Exception :
-> NotActiveException : If IO stream is not ready to be read
-> InvalidObjectException : if the argumented object to be validated is NULL.
  • resolveObject(Object o) : java.io.ObjectInputStream.resolveObject(Object o) sustituye un objeto por ObjectInputStream de otra subclase de confianza. No podemos reemplazar el objeto hasta que 
    se llame a enableResolveObject. Se llama después de que se ha leído un objeto. 
    Sintaxis:
protected Object resolveObject(Object o)
Parameters : 
o : object we want to substitute
Return : 
---------
Exception :
-> IOException : If IO error occurs.
  • enableResolveObject() : java.io.ObjectInputStream.enableResolveObject(verificación booleana) permite que el método resolveObject sustituya un objeto por ObjectInputStream de otra clase confiable. 
    se llama a enableResolveObject. Se llama después de que se ha leído un objeto. 
    Sintaxis:
protected boolean enableResolveObject(boolean enable)
Parameters : 
check : "true" to allow resolveObject() method
Return : 
----
  • readClassDescriptor() : java.io.ObjectInputStream.readClassDescriptor() lee el descriptor de clase del flujo serializado, se llama a este método si ObjectInputStream acepta el descriptor. Por defecto, el descriptor es llamado por el método readClassDescriptor() acc. al formato definido en 
    Sintaxis de serialización de objetos:
protected ObjectStreamClass readClassDescriptor()
Parameters : 
-------
Return : 
reads class descriptor
  • readObjectOverride() : java.io.ObjectInputStream.readObjectOverride() lee el objeto de ObjectOutputStream usando un constructor protegido sin argumentos 
    Sintaxis:
protected Object readObjectOverride()
Parameters : 
-------
Return : 
reads object from the Stream
  • readStreamHeader(): java.io.ObjectInputStream.readStreamHeader() permite que la subclase lea y verifique su encabezado y verifique el número de versión 
    Sintaxis:
protected void readStreamHeader()
Parameters : 
-------
Return : 
void
  • resolveProxyClass(String[] in_list) : java.io.resolveProxyClass(String[] in_list) devuelve una clase de proxy que implementa las interfaces que se nombran en el Descriptor de clase de proxy. Con este método, podemos leer los descriptores de las clases de proxy dinámico 
    Sintaxis:
protected Class resolveProxyClass(String[] in_list)
Parameters : 
in_List : interface names list, deserialized in the proxy class descriptor
Return : 
Proxy class for specific Interface mentioned in the list

Publicación traducida automáticamente

Artículo escrito por GeeksforGeeks-1 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *