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
package com.hxh.spring.test;
 
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;
 
public class LogTest {
 
    private final static Logger logger = LoggerFactory.getLogger(LogTest.class);
 
    @Test
    public void testLog() throws FileNotFoundException {
        int count = 0;
        String path = "";
        Scanner scanner = new Scanner(new FileInputStream("C:\\Users\\Administrator\\Desktop\\日志\\布丸播放\\video_play.2021-03-05.log"));
        while (scanner.hasNextLine()) {
            String text = scanner.nextLine();
            if (text != null && text.contains("getVideoDetail:")) {
                count++;
            }
        }
        scanner.close();
        System.out.println(count);
    }
}