Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package serialization;
- import java.io.*;
- import java.io.Serializable;
- public class SerializationSample {
- public static void main(String[] args) throws IOException{
- Student st =new Student(1);
- FileOutputStream fs =new FileOutputStream("student.ser");
- ObjectOutputStream os =new ObjectOutputStream(fs);
- os.writeObject(st);
- os.close();
- }
- }
- class Student implements Serializable{
- int id;
- public Student(int id){
- this.id = id;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement