?? log.java
字號:
package merge;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;
public class Log {
private File log;
private FileWriter fw;
private PrintWriter out;
public Log(){
log=new File("syslog.txt");
try{
fw=new FileWriter(log,true);
out=new PrintWriter(fw);
}catch(Exception e){
e.printStackTrace();
}
}
public void setFile(File f){
log=f;
}
public File getLog(){
return this.log;
}
public void addMes(String str){
if(this.out==null||str==null)return;
out.write(str);
out.println();
}
public void addTime(String str){
if(this.out==null)return;
String time=(new SimpleDateFormat
("yyyy-MM-dd hh:mm:ss"))
.format((new GregorianCalendar())
.getTime());
out.write(time+"\t"+str);
out.println();
}
public void writeLog(){
out.flush();
}
public void closeLog(){
try{
out.close();
fw.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -