当前位置:网站首页>分析日志.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;
}
边栏推荐
猜你喜欢

游戏资产复用:更快找到所需游戏资产的新方法

lvgl 说明3关于lvgl guider的使用
![[batch dos-cmd command - summary and summary] - environment variables, path variables, search file location related instructions - set, path, where, what if there are spaces in the path parameters of](/img/ca/0b96294336810187e833429fcea5bf.png)
[batch dos-cmd command - summary and summary] - environment variables, path variables, search file location related instructions - set, path, where, what if there are spaces in the path parameters of

JS print 99 multiplication table

Helix QAC更新至2022.1版本,将持续提供高标准合规覆盖率

PayPal账户遭大规模冻结!跨境卖家如何自救?

win命令行中导入、导出数据库相关表

Remote connection raspberry pie in VNC Viewer Mode

盲测调查显示女码农比男码农更优秀

二叉树结构以及堆结构基础
随机推荐
(resolved) the following raise notimplementederror occurs when Minet tests
二叉树结构以及堆结构基础
js用switch输出成绩是否合格
Closure problem
[13. number and bit operation of 1 in binary]
Mobile security tools -jad
Binary tree structure and heap structure foundation
游戏资产复用:更快找到所需游戏资产的新方法
L'enquête en aveugle a montré que les femmes étaient meilleures que les hommes.
洛谷刷题心得记录
期货反向跟单—交易员的培训问题
参考 | 升级 Win11 移动热点开不了或者开了连不上
[batch dos-cmd command - summary and summary] - parameters%0,%1,%2,%[0-9],%0-9 in the batch command and batch command parameter position switching command shift, operator% usage in the DOS command
Read datasets iteratively with xgboost
關聯GIS:條條道路通UE5城
L'introduction en bourse de Wild Wind Pharmaceutical a pris fin: Yu pinzeng, qui avait l'intention de lever 540 millions de RMB, a effectué un investissement P2P.
JS use switch to output whether the result is qualified
盲测调查显示女码农比男码农更优秀
JS to judge the odd and even function and find the function of circular area
JS to determine whether the result is qualified, the range is 0-100, otherwise re-enter