This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading contents of file into a Map
 
Similar Threads
Help Needed regarding reading the csv file
Reading of file contents and then outputting it into a database
Modify Newline character in java
Html question : href to a file : how to make it dynamic link?
B&S 2.2.2 - Network Layer Query