怎么把java日志写到windows系统日志里
发布网友
发布时间:2022-05-25 04:12
我来回答
共1个回答
热心网友
时间:2024-06-13 18:18
日志文件在哪个目录,用fileinputstream读文件就行了
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class FileReaderTest {
static List<String> logs = new ArrayList<String>();
public static List<String> readFile(File f) throws IOException {
if (f == null || !f.exists()) {
return null;
}
List<String> list = new ArrayList<String>();
String encoding = "UTF-8";
InputStreamReader read = new InputStreamReader(new FileInputStream(f),
encoding);
BufferedReader br = new BufferedReader(read);
String line = null;