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 lines[] = taOutput.getText().split("\\n");
for(int i = 0; i < lines.length; i++) {
System.out.println("Value: " + i);
BufferedWriter bw = new BufferedWriter(new FileWriter("audits.txt"));
String s = lines[i];
bw.write(s);
bw.flush();
bw.close();
}
}
catch(IOException ioe) {
System.out.println("Exception Caught : " +ioe.getMessage());
}
}
});
return btnSave;
}
So my program outputs port numbers into a textarea, i wish to write these results from the textarea into a text file. I hope to write the different ports line by line into the file, so i have created the String array. So to illustrate when i run my program i may get the following:
1
22
320
1200
So instead of writing to a file and the file containing 1223201200, i have set up the array, where also i have used a System.out to display for my viewing pleasure the contents of array (well index contents). So how would i write this array to file?
Thank you.