Datasets:

ArXiv:
License:
File size: 640 Bytes
c574d3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.io.*;

class StudentSeriliazation {
    public static void main(String... args) {
        try (FileOutputStream fout = new FileOutputStream("f.txt");
                ObjectOutputStream out = new ObjectOutputStream(fout);) {
            // Creating the object
            Student s1 = new Student(21, "Akash");
            // Write the object into the file
            out.writeObject(s1);
            // Flush the output stream pipe
            out.flush();
            System.out.println("success");
        } catch (Exception e) {
            System.out.println("failure");
            System.out.println(e);
        }
    }
}