Hello developers, i have got a problem that i have been trying to solve all day and would be glad if anyone here can help.
I have a Java port scanning application which scans for open ports and displays the results in a textarea called "taOutput" when the user clicks on the "Save" button.
Here is my code:
private JButton getBtnSave() {
if(btnSave == null) {
btnSave = new JButton();
btnSave.setToolTipText("Save scan output");
btnSave.setText("Save");
btnSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
try {
String s = taOutput.getText();
File f = new File("audits.txt");
FileWriter fw = new FileWriter(f);
fw.write(s);
}
catch(IOException ioe) {
System.out.println("Exception Caught : " +ioe.getMessage());
}
}
});
}
return btnSave;
}
Problem i have is that when i click on the "Save" button the port scan results are not written to the text file i have specified. Can anybody sense what is missing here?
Kind regards
Kevin.