File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need help with tab delimited scanning" Watch "Need help with tab delimited scanning" New topic

Need help with tab delimited scanning

michael montalbano

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: 74

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.

Stephan van Hulst

Joined: Sep 20, 2010
Posts: 4624

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.

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
I agree. Here's the link:
subject: Need help with tab delimited scanning
It's not a secret anymore!