当前位置:网站首页>分析日志.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例题打印1-100之间所有7的倍数的个数及总和
- ACM course term summary
- 關聯GIS:條條道路通UE5城
- Mobile security tools -jad
- 准备好迁移上云了?请收下这份迁移步骤清单
- [12. maximum continuous non repeating subsequence]
- MySQL about auto increment sum cannot be empty
- Speech signal processing - concept (4): Fourier transform, short-time Fourier transform, wavelet transform
- c的时间函数算效率
- Cookie encryption 7 fidder analysis phase
猜你喜欢

盲測調查顯示女碼農比男碼農更優秀
![log4j:WARN No such property [zipPermission] in org. apache. log4j. RollingFileAppender.](/img/2c/425993cef31dd4c786f9cc5ff081ef.png)
log4j:WARN No such property [zipPermission] in org. apache. log4j. RollingFileAppender.

Programming life - what do you think of the 35 year old bottleneck of programmers?
![[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

Experience record of Luogu's topic brushing
![[c++ primer notes] Chapter 4 expression](/img/cb/d543dd1f461653e9adf399b42d1d26.png)
[c++ primer notes] Chapter 4 expression

What is a magnetic separator?

爬一个网页的所有导师信息

索引+sql练习优化

L'enquête en aveugle a montré que les femmes étaient meilleures que les hommes.
随机推荐
关联GIS:条条道路通UE5城
【c ++ primer 笔记】第4章 表达式
基础知识 | js基础
Set the address book function to database maintenance, and add user name and password
Game asset reuse: a new way to find required game assets faster
【c ++ primer 笔记】第3章 字符串、向量和数组
JS performance reward and punishment examples
[11. two dimensional difference]
js例题打印1-100之间所有7的倍数的个数及总和
JS to print prime numbers between 1-100 and calculate the total number of optimized versions
sql注入之order by注入
Speech signal processing - concept (4): Fourier transform, short-time Fourier transform, wavelet transform
MSSQL how to export and delete multi table data using statements
After working in a large factory for ten years with an annual salary of 400000 yuan, I was suddenly laid off. If the company wanted to abandon you, it wouldn't leave any kindness
无论LCD和OLED显示技术有多好,都无法替代这个古老的显示数码管
【13. 二进制中1的个数、位运算】
js输出形状
JS to judge the odd and even function and find the function of circular area
Speech synthesis: tacotron explains [end-to-end speech synthesis model] [compared with traditional speech synthesis, it does not have complex phonetics and acoustic feature modules, but only uses < te
PayPal账户遭大规模冻结!跨境卖家如何自救?