Java读取txt
GA666666
2021-05-24 PM
21℃
0条
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
public class ReadText {
public static void main(String[] args) throws IOException {
File file = new File("E:\\maze.txt");
FileInputStream inputStream = new FileInputStream(file);
InputStreamReader in = new InputStreamReader(inputStream);
BufferedReader reader = new BufferedReader(in);
String res;
while((res=reader.readLine())!=null){
//分割空格并转化为数组
char[] ch = res.toCharArray();
System.out.println(res);
}
}
}