-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay1Git.java
More file actions
29 lines (25 loc) · 742 Bytes
/
Day1Git.java
File metadata and controls
29 lines (25 loc) · 742 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
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
public class Day1Git {
private String str;
private String fileName;
public Day1Git(String str, String fileName) {
this.str = str;
this.fileName = fileName;
}
public void readFileToStr() throws IOException {
BufferedReader br = new BufferedReader(new FileReader(fileName));
while (br.ready()) {
str = str + (char) br.read();
}
br.close();
}
public void strToFile() throws FileNotFoundException {
PrintWriter pw = new PrintWriter(fileName);
pw.print(str);
pw.close();
}
}