logo

NAME:SHRAVAN S REGISTRATION NUMBER:19BCE2548 1)Write your

3 Pages394 Words35 Views
   

Added on  2020-09-25

NAME:SHRAVAN S REGISTRATION NUMBER:19BCE2548 1)Write your

   Added on 2020-09-25

ShareRelated Documents
NAME:SHRAVAN SREGISTRATION NUMBER:19BCE25481)Write your informaton [as string as well as MyInfo Class object] like regno, name, cgpa and phnointo a fle and read from the fle and print in the console. Use Serializaton and Deserializaton inthe program.package com.package2;import java.io.*;class MyInfo implements Serializable{String name, registration;double cgpa;long phone;public MyInfo(String Name,String regno,double cgpa,long phno){this.name =Name;this.registration =regno;this.cgpa=cgpa;this.phone =phno;}}public class Main{public static void main(String[] args) throws FileNotFoundException,IOException,ClassNotFoundException{MyInfo s1=new MyInfo("Shravan","19BCE2548",8.21,769584477);FileOutputStream fout=new FileOutputStream("C:\\Users\\SID\\Documents\\MyInfo.txt");FileInputStream fin=new FileInputStream("C:\\Users\\SID\\Documents\\MyInfo.txt");ObjectOutputStream out=new ObjectOutputStream(fout);out.writeObject(s1);out.flush();System.out.println("Serialization successful!");System.out.println();ObjectInputStream in=new ObjectInputStream(fin);MyInfo s2=(MyInfo)in.readObject();System.out.println(s2.registration +" "+s2.name +" "+s2.cgpa+" "+s2.phone);System.out.println("Deserialization successful!");}}OUTPUT:
NAME:SHRAVAN S REGISTRATION NUMBER:19BCE2548 1)Write your_1

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Java Code import java.util.Scanner; /** * * File name
|2
|257
|314

Java Code for Writing into a File Solution 2022
|4
|550
|20

CS4348 - Operating Systems Concepts
|5
|1324
|177

Zoo Management System | Assignment
|8
|659
|163

/*. * To change this license header, choose License Hea
|3
|469
|309

Java Data Types, Expressions, Loops, and Dynamic Binding
|7
|1486
|129