How to make an object into serialize object

#2
public class implements Serializable{
public static void main(String []args) throws Exception{
FileOutputStream fos=new FileOutPutStream("abc.txt")
ObjectOutputStream oos=new ObjectOutputStream(fos);
fos.writeObject();
}
}

//here i have given main idea how to do it.implement according to ur requirment
 
#3
Dear friend's,
Serialization is the process of saving an object in a storage medium (such as a file, or a memory buffer) or to transmit it over a network connection in binary form.
In otherword we can say "Writing or storing state of an object in flat file" is serelization.
The object of any class to be serialized must implement Serializable interface.

Here is the code of program:

import java.io.*;


public class SerializingObject{

public static void main(String[] args) throws IOException{

BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Please enter File name : ");

String file = in.readLine();

System.out.print("Enter extention : ");

String ext = in.readLine();

String filename = file + "." + ext;

File f = new File(filename);

try{

ObjectOutput ObjOut = new ObjectOutputStream(new FileOutputStream(f));

ObjOut.writeObject(f);

ObjOut.close();

System.out.println("Serializing an Object Creation completed successfully.");

}

catch(IOException e){

System.out.println(e.getMessage());

}

}

}

Hope u will understand for any clarification u can write me
Regards,
gyan
 
Top