JFileChooser jfc=new JFileChooser();
//弹出框名称
jfc.setDialogTitle("文件存储");
//按照默认方式显示
jfc.showSaveDialog(null);
jfc.setVisible(true);
//文件路径
String file=jfc.getSelectedFile().getAbsolutePath();
//准备写入到指定文件
FileWriter fw=null;
BufferedWriter bw=null;
try{
fw=new FileWriter(file);
bw=new BufferedWriter(fw);
//存储
bw.write(this.jta.getText());
}
catch(Exception e1 ){
e1.printStackTrace();
}
finally
{
try {
fw.close();
bw.close();
} catch (IOException e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
}
你外面在catch一下IOException应该就好了吧
说的很明白了stramclose;去查看一下你的demo1第44行