File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
Register / Login
JavaRanch » Java Forums » Other Languages » Groovy
Reply 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
Sheriff

Joined: Jul 11, 2001
Posts: 15040

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.


My Blog | DZone Articles
Ivan Krizsan
Bartender

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

Best wishes!
 
 
subject: Reading contents of file into a Map
 
Threads others viewed
Help Needed regarding reading the csv file
B&S 2.2.2 - Network Layer Query
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?
MyEclipse, The Clear Choice