package com.hxh.spring.test.log;
|
|
import org.junit.Test;
|
|
import java.io.File;
|
import java.io.FileInputStream;
|
import java.io.FileNotFoundException;
|
import java.util.Scanner;
|
|
/**
|
* @author Administrator
|
* @title: LogTest
|
* @description: TODO
|
* @date 2021/10/11 14:46
|
*/
|
public class LogTest {
|
|
@Test
|
public void access() throws FileNotFoundException {
|
|
Scanner scanner = new Scanner(new FileInputStream(new File("C:\\Users\\Administrator\\Downloads\\202110111057018682009979\\localhost_access_log.2021-10-11.txt")));
|
while (scanner.hasNextLine()) {
|
String content = scanner.nextLine();
|
if (content.contains("comment")) {
|
System.out.println(content);
|
}
|
}
|
scanner.close();
|
|
}
|
|
|
}
|