Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2012
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. package serialization;
  2.  
  3. import java.io.*;
  4. import java.io.Serializable;
  5.  
  6. public class SerializationSample {
  7.  
  8.     public static void main(String[] args) throws IOException{
  9.         Student st =new Student(1);
  10.         FileOutputStream fs =new FileOutputStream("student.ser");
  11.         ObjectOutputStream os =new ObjectOutputStream(fs);
  12.         os.writeObject(st);
  13.         os.close();
  14.     }
  15. }
  16.  
  17. class Student implements Serializable{
  18.    
  19.     int id;
  20.    
  21.     public Student(int id){
  22.         this.id = id;
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement