aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to read string and int from a jTextField into a txt file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to read string and int from a jTextField into a txt file" Watch "How to read string and int from a jTextField into a txt file" New topic
Author

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

Marcelo Bordolli
Ranch Hand

Joined: Sep 03, 2012
Posts: 46

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!


I know is only java
BUT I LIKE IT!!!
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Sep 03, 2012
Posts: 46

Thank you Michael Dunn!!!
i did what you told me and it work better than fine!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to read string and int from a jTextField into a txt file