can write code for serialization ?
Answer / bharat shivram
import java.io.*;
public class SerializationDemo {
public static void main(String args[]) {
// Object serialization
try {
MyClass object1 = new MyClass("Hello", -7, 2.7e10);
System.out.println("object1: " + object1);
FileOutputStream fos = new FileOutputStream("serial");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(object1);
oos.flush();
oos.close();
}
catch(Exception e) {
System.out.println("Exception during serialization: " + e);
System.exit(0);
}
Is This Answer Correct ? | 3 Yes | 0 No |
What are null interfaces in JAVA ? and give me some examples?
Is class is a data type?
What is finalize()?
What is nested loop? What is dangling else condition in it?
Can we split string with in java?
what is main purpose of abstract class?
How to sort elements in a parallel array in java?
What is a conditional statement explain with example?
What problems will occur when you don?t use layout managers?
How can a gui component handle its own events?
What is a reflection package?
Thanks A.jyotsna, Can u tell me differnce between abstract class and interface vikash