maven学习

第一段

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
public class  {
public static void writeLog(String content) {
try {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
HttpSession session = WebContextFactory.get().getSession();//设置操作人员
String operator = (String)session.getAttribute("userName");
String fileName = Init.getDir("log");
//打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件
FileWriter writer = new FileWriter(fileName, true);
writer.write(df.format(new Date()) + ' ' + operator + ' '+ content + "rn");
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}

public static String readLog() throws IOException{
String fileName = Init.getDir("log");
File file=new File(fileName);
if(!file.exists()||file.isDirectory())
throw new FileNotFoundException();
BufferedReader br=new BufferedReader(new FileReader(file));
String temp=null;
StringBuffer sb=new StringBuffer();
temp=br.readLine();
while(temp!=null){
temp += "rn";
sb.insert(0, temp);
temp=br.readLine();
}
br.close();
return sb.toString();
}
}

第二段

付电费水费发射点范围
烦烦烦烦烦烦