package com.company;
import java.io.*;
public class Main {
public static void main(String[] args) {
File file1 = new File("E:\\AH\\5062faf808c471d4a7ef738b89e62aa8.m3u8"); // 创建File类对象
FileInputStream fis = null;
InputStreamReader isr = null;
BufferedReader br = null;
try {
try {
fis = new FileInputStream(file1);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
isr = new InputStreamReader(fis);
br = new BufferedReader(isr);
String lineTxt = null;
// 从缓冲区中逐行读取代码,调用readLine()方法
while ((lineTxt = br.readLine()) != null) {
if (lineTxt.contains(".ts")) { //判断关键字
System.out.println(lineTxt); // 逐行输出文件内容
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
// 关闭数据流
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (isr != null) {
try {
isr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}