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 question about Scanner and Arraylist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "question about Scanner and Arraylist" Watch "question about Scanner and Arraylist" New topic

question about Scanner and Arraylist

christopher persinger

Joined: Aug 23, 2005
Posts: 20
okay, im trying to read in this text file and only keep the lines with three tokens (lastname, firstname, and email). then i use these strings and make an object from them. then this object is placed in an ascending order arraylist... the problem is that one of the lines on the text file reads: "yo yo, ma , ... the whitespace makes this come at the beginning of the arraylist.. is there anyway to scan this line of text in to where it gets rid of the whitespace and reads it in as: firstname = yo yo, lastname = ma, and email = ??? Thanks! (Below is my code)

Georgy Bolyuba
Ranch Hand

Joined: Feb 18, 2005
Posts: 162
Hi, christopher.

I have two questions for you:

1. Do really need another method for scanning line or maybe there are some methods in java.lang.String class that can help you trim your whitespaces?

2. You have implemented compareTo method for Customer class but still the container you use cannot sort your Customer's and you have to do it by yourself. Sorting is frequent task and maybe you can find a container in core Java packages which can sort your list for you?

Think about it.
[ September 02, 2005: Message edited by: George Bolyuba ]

SCJP 1.4 (100%) Done.<br />SCJD (URLyBird 1.2.3 Started)
I agree. Here's the link:
subject: question about Scanner and Arraylist
It's not a secret anymore!