📄 pop3_logformailbox.java
字号:
package Server.POP3;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.Date;
import Server.Server;
import Server.SMTP.SMTP_Final;
public class POP3_LogForMailBox extends Server {
private Socket socket;
private String name;
private String receive;
public POP3_LogForMailBox(Socket socket) {
super();
this.socket = socket;
}
public POP3_LogForMailBox(String name, String receive) {
this.name = name;
this.receive = receive;
}
public void makeLogFile() {
FileOutputStream fos = null;
try {
String currentDay = new SimpleDateFormat("yyyyMMdd")
.format(new Date());
fos = new FileOutputStream(SMTP_Final.logFilePath + "/"
+ currentDay + ".log", true);
PrintWriter pw = new PrintWriter(new OutputStreamWriter(fos),true);
pw.println();
pw.println("用户:"+name);
pw.println("行为:接收邮件"+receive);
pw.println("时间:"+new SimpleDateFormat("yyyy-MM-dd hh:mm:ss:SSS aaa").format(new Date()));
pw.flush();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (fos != null) {
fos.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public void run() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -