Results 1 to 7 of 7
Thread: how would i get this to work...?
- 12-06-2007, 12:39 AM #1
Member
- Join Date
- Dec 2007
- Posts
- 5
- Rep Power
- 0
how would i get this to work...?
private void requestJButtonActionPerformed (ActionEvent event)
{
Writer fw = null;
try
{
fw = new FileWriter( "customer.txt" );
fw.write( phoneJTextField + "," + postcodeJTextField );
}
catch ( IOException e ) {
System.err.println( "Cannot write to file" );
}
finally {
if ( fw != null )
try { fw.close(); } catch ( IOException e ) { }
}
}
- 12-06-2007, 12:54 AM #2
Java Code: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()); } }
- 12-06-2007, 01:08 AM #3
Member
- Join Date
- Dec 2007
- Posts
- 5
- Rep Power
- 0
sorry i should have explained the programme i guess.
phoneJTextField etc will have user input on a form.
when a button is pressed i would like the programme to write what is in the fields to file...having trouble getting this working :(
- 12-06-2007, 01:30 AM #4
Senior Member
- Join Date
- Nov 2007
- Location
- Newport, WA
- Posts
- 141
- Rep Power
- 0
That should be in your ActionListener for the button you press.Java Code:BufferedWriter wrt = new BufferedWriter(new FileWriter( "test/test2.txt")); wrt.append(phoneJTextField.getText()); wrt.close();
- 12-06-2007, 02:11 AM #5
Member
- Join Date
- Dec 2007
- Posts
- 5
- Rep Power
- 0
im still stuck with htis :( can i email the code to someone to take a look at and sort out?
thanks
- 12-06-2007, 02:27 AM #6
You can post it here or send it in a PM.
- 12-06-2007, 02:58 AM #7
Senior Member
- Join Date
- Nov 2007
- Location
- Newport, WA
- Posts
- 141
- Rep Power
- 0
Similar Threads
-
Synchronization Doesn't seem to work
By sherinpearl in forum Threads and SynchronizationReplies: 1Last Post: 04-23-2008, 06:30 PM -
Will this applet ever work?
By willemjav in forum Java AppletsReplies: 4Last Post: 04-20-2008, 05:40 PM -
Work On Lucene
By peiceonly in forum LuceneReplies: 1Last Post: 08-07-2007, 05:47 PM -
what do I have to install to work with JSP
By boy22 in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 08-05-2007, 04:08 AM -
Program don't work
By baltimore in forum New To JavaReplies: 1Last Post: 08-04-2007, 09:51 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks