-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSem2_T3_4.java
More file actions
34 lines (27 loc) · 980 Bytes
/
Sem2_T3_4.java
File metadata and controls
34 lines (27 loc) · 980 Bytes
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
import java.io.*;
// BufferedWriter
// this class is used to wrtie data into the file.
// BufferedWriter can't male direct connection with file.
public class Sem2_T3_4 {
public static void main(String[] args) throws IOException {
// FileWriter fw1 = new FileWriter("D:\\Demo.txt");
// BufferedWriter bw1 = new BufferedWriter(fw1);
// Combine version
BufferedWriter bw1 = new BufferedWriter(new FileWriter("D:\\Demo.txt"));
bw1.write(65); // 65
bw1.write("BCD");
bw1.newLine(); // we use for go to new line in String.
bw1.write("End");
bw1.close();
// BufferedReader
BufferedReader br1 = new BufferedReader(new FileReader("D:\\Demo.txt"));
String l = br1.readLine();
while (l != null) {
System.out.println(l);
l = br1.readLine();
}
// ABCD
// End
br1.close();
}
}