import java.io.*;
public class SerializingObject_demo{
public static void main(String[] args) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Please enter name of the File : ");
String file = in.readLine();
System.out.print("Enter the extention : ");
String ext = in.readLine();
String filename = file + "." + ext;
File f1 = new File(filename);
try{
ObjectOutput ObjOut = new ObjectOutputStream(new FileOutputStream(f));
ObjOut.writeObject(f1);
ObjOut.close();
System.out.println("Serializing completed successfully.");
}
catch(IOException e){
System.out.println(e.getMessage());
}
}
}
Bookmarks