Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

from text file into textfields  RSS feed

 
Rodney Ibanez
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! Please help. I'm beginning to understand a bit about java thanks to this forum but could you help me with this problem?

Say I create a text file "Info.txt" and I saved in it the name and address of a person. I would like to retrieve each of the data in the text file and place it in a Jtextfield name and JTExtField address then click a button so I can go to the next data in the text file. I've searched all over the internet and I couldn't find a solution or a sample at least. Could you give me a sample and I would take it a bit further on my own so I may practice. Thank you!

btw, could you make it that I would be using buffered reader instead of scanner. I think buffered reader is a bit advanced than using scanner.
 
Tony Docherty
Bartender
Posts: 3200
78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We won't write the code for you but will guide you.
If you want to write separate pieces of data to a file and retrieve them you need to decide how you want to format the file so you can identify each of the chunks of data. There are standard formats such as CSV, XML, Properties files etc or you could come up with your own system if you really want to reinvent the wheel.

Why do you think BufferredReader is more advanced than Scanner?
 
Rodney Ibanez
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:We won't write the code for you but will guide you.
If you want to write separate pieces of data to a file and retrieve them you need to decide how you want to format the file so you can identify each of the chunks of data. There are standard formats such as CSV, XML, Properties files etc or you could come up with your own system if you really want to reinvent the wheel.

Why do you think BufferredReader is more advanced than Scanner?


I'm sorry. I never meant for the people to code it for me. I just want to know how to start it or how do I go about it. I tried using the scanner class actually but the the problem is, I can only place the last data into the text fields. If only I can make it so that i can pass each of the data in my "textFile.txt" and just press another button to continue to the next data. Thank you. Below is the code that I've done so far..

 
Tony Docherty
Bartender
Posts: 3200
78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what does the data file look like?

Your ClassOne class (is that really the most appropriate name for describing what the class represents?) shouldn't set static variables from instance methods. 'name' and 'surnNme' should be instance variables and preferably they should be private.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!