aspose file tools*
The moose likes Groovy and the fly likes Reading contents of file into a Map Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Reading contents of file into a Map" Watch "Reading contents of file into a Map" New topic
Author

Reading contents of file into a Map

Bill Lee
Greenhorn

Joined: Feb 02, 2007
Posts: 20
I am working on a script of reading the contents of a file directly into a map. I have no issues reading into list. But basically have a file that has 2 fields separated by a comma (i.e.

Chicago, IL
Sacramento, CA

Is this something that anyone has had experience with? Thanks.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

What are you wanting for the key and value in the map? Something like...

[Chicago:IL]

???

We need more info as to what you are trying to achieve. This is just a guess.


GenRocket - Experts at Building Test Data
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
If you want a map with the city as key and the state as value, then try this:

Best wishes!
 
Consider Paul's rocket mass heater.
 
subject: Reading contents of file into a Map