aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "question about Scanner and Arraylist" Watch "question about Scanner and Arraylist" New topic
Author

question about Scanner and Arraylist

christopher persinger
Greenhorn

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 , yoyoma@email.com ... 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 = yoyoma@email.com ??? 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: http://aspose.com/file-tools
 
subject: question about Scanner and Arraylist
 
Similar Threads
Question on String Tokenizer .
Pesudo coding
help with database!
question, please help.
Student schedule