我是 java 新手,我正试图在按下按钮时做到这一点,它将更新放在表中的新信息。我收到此错误:
unreported exception java.io.IOException; must be caught or declared to be thrown
这是我遇到问题的代码:
public static void updateAction(){
update.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
BufferedWriter bfw = new BufferedWriter(new FileWriter(tmp));
for(int i = 0 ; i < table.getColumnCount() ; i++)
{
bfw.write(table.getColumnName(i));
bfw.write("\t");
}
for (int i = 0 ; i < table.getRowCount(); i++)
{
bfw.newLine();
for(int j = 0 ; j < table.getColumnCount();j++)
{
bfw.write((String)(table.getValueAt(i,j)));
bfw.write("\t");;
}
}
bfw.close();
}});
}
感谢你给与我的帮助。