//Skip to content
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.ObjectOutputStream;
-
- public class SERIALIZATION_INTERFACE {
-
- public static void main(String[] args) {
-
- Employee employee=new Employee();
- employee.id=10;
- employee.name="Adam";
-
- try {
- FileOutputStream fOutputStream=new FileOutputStream("G:/employee.ser");
- ObjectOutputStream outputStream=new ObjectOutputStream(fOutputStream);
- outputStream.writeObject(employee);
- outputStream.flush();
- outputStream.close();
- fOutputStream.close();
- System.out.println("Data saved");
- } catch (IOException e) {
-
- e.printStackTrace();
- }
-
- }
-
- }
-
-
-
-
- import java.io.Serializable;
-
- public class Employee implements Serializable {
-
- transient public int id;
- transient public String name;
-
- public void getName(){
- System.out.println("Employee name : "+name);
- }
-
- public void getId() {
- System.out.println("Employee id : "+id);
- }
-
- }
I am Md Abdullah Al Hasan. I have completed my graduation in Computer Science and Engineering from Jashore University of Science and Technology.
0 Comments:
Post a Comment