📄 errorloger.java
字号:
package com.javahomework.Server.Log;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
public class ErrorLoger implements Loger {
private String fileName = "Exception.Log";
private PrintWriter out = null;
public ErrorLoger() {
}
public synchronized void save(LogContent logContent) {
out.print(logContent.getIp() + "\t");
out.print(logContent.getPort() + "\t");
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");// 取得格式化日期
out.print(df.format(logContent.getDate()) + "\t");// 格式化日期输出
out.println(logContent.getContent());
out.flush();
}
public void open() {
try {
out = new PrintWriter(new FileOutputStream(fileName,true));
} catch (Exception e) {
e.printStackTrace();
}
}
public void close() {
try {
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -