-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logger.java
41 lines (33 loc) · 1 KB
/
Logger.java
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
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
public class Logger {
public static void addlog(String log) throws IOException{
File logs = new File("logs.txt");
String temp=log;
BufferedReader reader;
reader = new BufferedReader(new FileReader("logs.txt"));
String line = reader.readLine();
while (line != null) {
temp=temp+"\r\n"+line;
line = reader.readLine();
}
reader.close();
PrintWriter writer = new PrintWriter("logs.txt");
writer.write(temp);
writer.close();
}
static void openLog(){
ProcessBuilder pb = new ProcessBuilder("Notepad.exe","logs.txt");
try {
pb.start();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}