JTextField phoneJTextField = new JTextField("Beachwood 45789");
JTextField postcodeJTextField = new JTextField("99231");
Writer fw = null;
try
{
fw = new FileWriter( "customer.txt" );
String phoneNumber = phoneJTextField.getText();
String postalCode = postcodeJTextField.getText();
fw.write( phoneNumber + "," + postalCode );
}
catch ( IOException e ) {
System.err.println( "Cannot write to file" );
}
finally {
if ( fw != null )
try {
fw.close();
} catch ( IOException e ) {
System.out.println("Close error: " + e.getMessage());
}
}