-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQue-47.java
More file actions
33 lines (33 loc) · 1.26 KB
/
Copy pathQue-47.java
File metadata and controls
33 lines (33 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//Create a class called Student. Write a student manager program to manipulate the student information from files by using FileInputStream and FileOutputStream.
//By: Parth Panjwani
import java.io.*;
class Student {
String name;
int rollno;
String address;
int marks;
public Student(String name, int rollno, String address, int marks) {
this.name = name;
this.rollno = rollno;
this.address = address;
this.marks = marks;
}
public String toString() {
return "Name: " + name + "\nRoll No: " + rollno + "\nAddress: " + address + "\nMarks: " + marks;
}
}
class Que47 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("Student.txt"));
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("Student.txt"));
String s;
while ((s = br.readLine()) != null) {
String[] arr = s.split(" ");
Student st = new Student(arr[0], Integer.parseInt(arr[1]), arr[2], Integer.parseInt(arr[3]));
bos.write(st.toString().getBytes());
}
bis.close();
bos.close();
}
}