当前位置:网站首页>分析日志.log
分析日志.log
2022-06-27 08:04:00 【Stack Piston】
/**
* 读取日志,找出嫌疑人
*
* @param logFile 日志文件
* @throws
*/
@Test
public void testLog() {
List<String> paths = getFileName("C:\\Users\\cowain\\Desktop\\新建文件夹");
for (int i = 0; i < paths.size(); i++) {
File tmpLogFile = new File(paths.get(i));
try {
//指定文件可读可写
final RandomAccessFile randomFile = new RandomAccessFile(tmpLogFile, "r");
String tmp = "";
String pre = "";
while ((tmp = randomFile.readLine()) != null) {
String sb=new String();
String txt = new String(tmp.getBytes("ISO8859-1"));
if(txt.contains("CWA2179")){
sb+=System.getProperty("line.separator");
sb+=pre;
sb+=System.getProperty("line.separator");
sb+=txt;
try {
String path = "C:\\Users\\cowain\\Desktop\\王总日志.txt";
BufferedWriter out = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(path,true)));
out.write(sb+" ");
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
pre=txt;
}
} catch (IOException e) {
e.printStackTrace();
}
}
System.out.println("结束");
}
private List<String> getFileName(String filePath){
List<String> list=new ArrayList<>();
if(null!=filePath&&!"".equals(filePath)){
File file = new File(filePath);
//判断文件或目录是否存在
if(!file.exists()){
log.info("【"+filePath + " not exists】");
}
//获取该文件夹下所有的文件
File[] fileArray= file.listFiles();
File fileName = null;
for(int i =0;i<fileArray.length;i++){
fileName = fileArray[i];
list.add(fileName.getAbsolutePath());
}
}
return list;
}
边栏推荐
猜你喜欢

JS example print the number and sum of multiples of all 7 between 1-100

js中如何查看程序运行时间(计时器)

关联GIS:条条道路通UE5城

【10. 差分】
![[batch dos-cmd command - summary and summary] - output / display command - echo](/img/44/cddad70eeb756db15c19100c25c61a.png)
[batch dos-cmd command - summary and summary] - output / display command - echo

lvgl使用demo及说明2

Error in idea connection database

Index +sql exercise optimization

No matter how good LCD and OLED display technologies are, they cannot replace this ancient display nixie tube

SIG associé: toutes les routes mènent à ue5
随机推荐
【批处理DOS-CMD命令-汇总和小结】-将文件夹映射成虚拟磁盘——subst
js打印99乘法表
What is a magnetic separator?
爬一个网页的所有导师信息
Read datasets iteratively with xgboost
盲測調查顯示女碼農比男碼農更優秀
JS performance reward and punishment examples
lvgl 说明3关于lvgl guider的使用
JS use switch to output whether the result is qualified
期货反向跟单—交易员的培训问题
Time function calculation efficiency of C
Etcd教程 — 第五章 Etcd之etcdctl的使用
SQL attendance query interval: one hour
Cookie encryption 6
闭包问题
File and multipartfile overview
JS to print prime numbers between 1-100 and calculate the total number of optimized versions
Speech signal processing - concept (II): amplitude spectrum (STFT spectrum), Mel spectrum [the deep learning of speech mainly uses amplitude spectrum and Mel spectrum] [extracted with librosa or torch
js中输入三个值,并且由小到大输出
盲测调查显示女码农比男码农更优秀