读取指定文件

public static void main(String[] args) throws IOException {
    //result为你要读取文件的地址,D:\\www.txt,或者D:/www.txt 写都可以
    FileInputStream fstream = new FileInputStream(new File("D:\\logs\\2021-02-19.log"));
    //构造一个InputStream对象,这个对象是字节流通向字符流的桥梁,它读取字节并将其解码为字符
    //构造一个BufferedReader,里面存放在控制台输入的字节转换后成的字符。
    BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
    String strLine;
    StringBuilder index = new StringBuilder();
    Map<Object, Object> retMap = new HashMap<Object, Object>();

    while ((strLine = br.readLine()) != null) {
        index.append(strLine).append("\r\n");//每读一条存入index
    }
    retMap.put("logdata", index);
    System.out.println(index.toString());
}