Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes Need help with tab delimited scanning Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need help with tab delimited scanning" Watch "Need help with tab delimited scanning" New topic
Author

Need help with tab delimited scanning

michael montalbano
Greenhorn

Joined: Oct 17, 2011
Posts: 4
I have a project for CSC220 that requires me to write a program that can read 35 different first names, last names, and email addresses from a text file. I am then to take these names and input them in a format that has the first name, last name, and email address seperate from eachother. I know how to read from the text file, but I can't figure out to make it so I can assign the first name to name1, the last name to name2, and the address to email. Instead, i've only been able to get it to print out all of it at once. can anyone point me in the right direction? It would be much appreciated
Claudiu Chelemen
Ranch Hand

Joined: Mar 25, 2011
Posts: 71

Hi and welcome!

I don't see where the problem is, since you already got the data from the file.
Could you please post the code you've got so far ?

You may store the data for each person in a simple pojo, eg. PersonView, in order to create a collection of these PersonViews.
Then you can manipulate the data in any way needed.

Cheers
Claudiu
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3599
    
  14

You might want to take a look at the Scanner class. It can break Strings up in so called tokens. By default, each token is considered to be everything separated by whitespace, which should be perfect for your problem.

Specifically, take a look at the methods hasNext() and next(), in the Scanner class.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help with tab delimited scanning
 
Similar Threads
dropdown related issue
sort problem
Sorting by using Comparator
Search for records in jsp with text box or any other way..
SortNames