Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to read string and int from a jTextField into a txt file

 
Marcelo Bordolli
Ranch Hand
Posts: 46
Android Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have an api that have 3 textfields:

name: (gere goes textfiel1)

Last Name: (Second textfiel)

Id: (number 3 textfield)

then i have a button named SAVE
and a txt were i have many names followed by last name and id, a list you may say

The thing is that wen i press SAVE i want to send the info from the 3 text fiels into the txt file
in order.

Would you ranchers give me some directions on how i can acomplish this?

THANK YOU IN ADVANCE!

 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the button's actionPerformed() create a String (line):

(the text from) tf1 + delimeter + (the text from) tf2 + delimeter + (the text from) tf3 + "\n"

where delimeter is a keyboard character unlikely to appear in any of the tf's e.g. ~ or |
(the delimeter is used to split the line when reading it back)

use a FileWriter (using the constructor that contains a boolean), and 'write' the line
 
Marcelo Bordolli
Ranch Hand
Posts: 46
Android Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Michael Dunn!!!
i did what you told me and it work better than fine!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic