Java.io - SPLessons

Java.io ObjectStreamClass

Home > Lesson > Chapter 32
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Java.io ObjectStreamClass

Java.io ObjectStreamClass

shape Introduction

The Java.io ObjectStreamClass is the class used for to serialize the classes which provides the name of the class and the UID serial version of the class. By making use of the lookup method the object stream class is created for represented class in JVM. 

Class Declaration

shape Declaration

Java.io ObjectStreamClass class is declared below: Public class ObjectStreamClass extends Object implements Serializale

shape Fields

Java.io ObjectStreamClass class fields are:
  • Static ObjectStreamField[] NO_FIELDS : The field represents the serial persistent field to indicate the fields which are non-serializable.

Class Methods

shape Table

Method Description
String toString To abstract path name the method returns the pathname string.
String getName() The files or directories which are denoted by its abstract pathname are named by this method.
Class<?> forClass() The function of this method is to retutn the class in local JVM to map with serial version.
long GetSerialversionUID() The function of this method is return the UID serial version to represented class.

Inherited Methods

shape Description

From the following classes, methods are inherited the ObjectStreamClass class.
  • Java.io.Object

shape Examples

Usage of long GetSerialversionUID() method. [c]import java.io.*; import java.util.Calendar; public class ObjectStreamClass { public static void main(String[] args) { // Creating a new object stream class for Integer ObjectStreamClass osc = ObjectStreamClass.lookup(Integer.class); // To get the serial version for Integer System.out.println("" + osc.getSerialVersionUID()); // creating a new object stream class for Calendar ObjectStreamClass osc2 = ObjectStreamClass.lookup(Calendar.class); // To get the serial for Calendar System.out.println("" + osc2.getSerialVersionUID()); } }[/c] Output Following is the result will be displayed. [c]1360826667806852920 -1807547505821590642[/c] Usage of String getName() method. [c]import java.io.*; public class ObjectStreamClass { public static void main(String[] args) { // creating a new object stream class for Integers ObjectStreamClass osc = ObjectStreamClass.lookup(Integer.class); // To get the name of the class and print it System.out.println("" + osc.getName()); } }[/c] Output Following is the result will be displayed. [c]java.lang.Integer [/c]

Summary

shape Key Points

  • The Java.io ObjectStreamClass is the class used for to serialize the classes which provides the name of the class and the UID serial version of the class.
  • By making use of the lookup method the Java.io ObjectStreamClass is created for represented class in JVM.