File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question about Scanner and Arraylist

 
christopher persinger
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 162
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic