static void parse(String fileName) throws IOException{
FileReader fileReader=new FileReader((fileName));
BufferedReader bufferedReader = new BufferedReader(fileReader);
StringBuilder stringBuilder=new StringBuilder();
String string;
do{
string=bufferedReader.readLine();
stringBuilder.append(string);
}while(!string.equals(null));
System.out.println(stringBuilder.toString());
}
我尝试使用 StringBuilder 将整个文件读取为字符串。但是我在while循环中出错。为什么?