我是 Java 新手,我有很多关于文本的工作,并且我有一个想法来制作一个简单的程序来完成我的工作。我收到错误Exception in thread "main" java.lang.NullPointerException at com.text.work.Main.main(Main.java:25)
public class Main {
public static void main(String[] args) throws IOException {
int someNumber = 0;
PrintWriter saveFileOne = new PrintWriter("save.txt");
PrintWriter saveFileTwo = new PrintWriter("otherThings.txt");
FileReader fileReader = new FileReader("read.txt");
BufferedReader bufferedReader = new BufferedReader(fileReader);
String word = bufferedReader.readLine();
do {
word = bufferedReader.readLine();
if (word.toString().equals("true")) { //this is line 25
saveFileOne.println("No: " + ++someNumber + " = " + word);
} else {
saveFileTwo.println("Yes: " + someNumber + " = " + word);
}
} while (word != null);
saveFileOne.close();
saveFileTwo.close();
bufferedReader.close();
System.out.println("Done!");
}
}