-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIO.java
More file actions
55 lines (44 loc) · 1.45 KB
/
Copy pathIO.java
File metadata and controls
55 lines (44 loc) · 1.45 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class IO {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
try{
BufferedWriter bw = new BufferedWriter(new FileWriter("R:\\PF\\Learning java\\New.txt"));
while(true){
System.out.print("Enter roll no : ");
int RNo = sc.nextInt();
sc.nextLine();
if(RNo==0)
break;
System.out.print("Enter name : ");
String name = sc.next();
System.out.print("Enter the marks : ");
int marks = sc.nextInt();
sc.nextLine();
bw.write("Roll no : " + RNo + "\n");
bw.write("Name : " + name + "\n");
bw.write("Marks : " + marks + "\n");
}
bw.close();
}
catch(IOException e){
e.printStackTrace();
}
try{
BufferedReader br = new BufferedReader(new FileReader("R:\\PF\\Learning java\\New.txt"));
String line ;
while((line= br.readLine())!=null){
System.out.println(line);
}
br.close();
}
catch(IOException e){
e.printStackTrace();
}
}
}