每次我尝试从.txt文件中读取时,我都会得到一个NullPointerException. 我已经查找了所有内容,但无论如何都找不到答案。如果有人能告诉我我做错了什么,那就太好了。
public class fileClassOpen implements ActionListener{
public void actionPerformed(ActionEvent e) {
int dialog = chooser2.showOpenDialog(Other.this);
if(dialog == JFileChooser.APPROVE_OPTION) {
String path = chooser.getSelectedFile().getAbsolutePath();
try {
FileReader fw = new FileReader(path);
BufferedReader br = new BufferedReader(fw);
while(br.readLine() != null) {
txtArea.setText(br.readLine());
}
} catch (IOException e1) {
}
}
}
}
米琪卡哇伊
达令说
繁花不似锦
相关分类