Java读取本地文件

背景:需要读取本地的log文件,并进行字符的分割

package com.wfbmall.interceptors.com.test;
import java.io.*;
public class test01{
    public static void main (String[] args) {
        try{
            BufferedReader in = new BufferedReader(new FileReader("C://Users//86159//Desktop//wfbmall_4.log"));
            String str;
            while ((str = in.readLine()) != null) {
                String[] tokens = str.split("  ");
                //System.out.println(tokens[0]);
                System.out.println(String.join("/t", tokens));
            }
            System.out.println(str);
        } catch(IOException e) {

        }
    }
}

 

posted @ 2021-04-15 11:07  欣欣姐  Views(608)  Comments(0)    收藏  举报