Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-06-2007, 01:39 AM
Member
 
Join Date: Dec 2007
Posts: 5
deeadeed is on a distinguished road
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 ) { }
}


}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-06-2007, 01:54 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,015
hardwired is on a distinguished road
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()); } }
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-06-2007, 02:08 AM
Member
 
Join Date: Dec 2007
Posts: 5
deeadeed is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-06-2007, 02:30 AM
Senior Member
 
Join Date: Nov 2007
Location: Newport, WA
Posts: 141
staykovmarin is on a distinguished road
Code:
BufferedWriter wrt = new BufferedWriter(new FileWriter( "test/test2.txt")); wrt.append(phoneJTextField.getText()); wrt.close();
That should be in your ActionListener for the button you press.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 12-06-2007, 03:11 AM
Member
 
Join Date: Dec 2007
Posts: 5
deeadeed is on a distinguished road
im still stuck with htis can i email the code to someone to take a look at and sort out?

thanks
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 12-06-2007, 03:27 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,015
hardwired is on a distinguished road
You can post it here or send it in a PM.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 12-06-2007, 03:58 AM
Senior Member
 
Join Date: Nov 2007
Location: Newport, WA
Posts: 141
staykovmarin is on a distinguished road
For those who read PMs. Although generally it is frowned upon by people like me, therefore i dont answer them, and there is no way in hell i am giving you my email. The forum is here for a reason.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Synchronization Doesn't seem to work sherinpearl Threads and Synchronization 1 04-23-2008 07:30 PM
Will this applet ever work? willemjav Java Applets 4 04-20-2008 06:40 PM
Work On Lucene peiceonly Lucene 1 08-07-2007 06:47 PM
what do I have to install to work with JSP boy22 JavaServer Pages (JSP) and JSTL 1 08-05-2007 05:08 AM
Program don't work baltimore New To Java 1 08-04-2007 10:51 PM


All times are GMT +3. The time now is 03:16 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org