代码拉取完成,页面将自动刷新
/**
*
*/
import java.io.*;
import java.util.*;
public class file{
public static void main(String[] args) throws IOException{
char ch;
while ((ch = (char) System.in.read()) != ' '){
System.in.skip(2);
log wl = new log(ch);
System.out.println("我们将记录您的输入:"+wl.write());
}
}
}
/**
* 记录日志
*/
class log{
String now;
Calendar date;
String content;
log(char con){
content = String.valueOf(con);
date = Calendar.getInstance();
now = date.get(date.YEAR)+"-"+(date.get(date.MONTH)+1)+"-"+date.get(date.DATE)+" "+date.get(date.HOUR_OF_DAY)+":"+date.get(date.MINUTE)+":"+date.get(date.SECOND);
}
public String write(){
content = now+" "+content;
// 写入日志文件
// FileReader in = new FileReader("log.txt");
// BufferedReader bin = new BufferedReader(in);
FileWriter out = new FileWriter("log.txt",true);
out.write(content+"\n");
out.close();
return content;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。