aspose file tools*
The moose likes Java in General and the fly likes  scan.useDelimiter( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark " scan.useDelimiter(",")" Watch " scan.useDelimiter(",")" New topic
Author

scan.useDelimiter(",")

Brett Freedman
Greenhorn

Joined: Feb 26, 2010
Posts: 13
I'm trying to read in a comma delimited file with Scanner. This works for me with the default space delimiter but I want to use comma since I have some team names with two words.

Here is my code:



Here is part of my input file:


Ireneusz Kordal
Ranch Hand

Joined: Jun 21, 2008
Posts: 423
Hi,

you must use , (comma) and \n (new line) as your delimiters, since lines are separated by new lines.
Try this:

Brett Freedman
Greenhorn

Joined: Feb 26, 2010
Posts: 13
Ireneusz Kordal wrote:Hi,

you must use , (comma) and \n (new line) as your delimiters, since lines are separated by new lines.
Try this:



Thanks, Ireneusz! This didn't entirely clear up my problem but got me going in the right direction. There were apparently some extra non-visible characters tacked onto the last field of each line mucking up the works. I ended up scanning in one line at a time, splitting that string into tokens and trimming the last field.
 
Don't get me started about those stupid light bulbs.
 
subject: scan.useDelimiter(",")