reading file into a hashmap?
hi out there.
i have a question :) of course, i have.
i need to parse a textfile. this file contains the following:
string1 = 1,2,3,4
string2 = 22,56,77
...
and so on. what i need first is the following:
get every string and number and put that into a hashmap. can i use an array as the values for the key "string"?
what is really intended is the following: i have to a call an external program that gets the arrays as attributes.
example:
"external_program -param string1=1 -param string2=22" and so on for every string.
next loop would be in this example "external_program -param string1=1 -param string2=56" so to iterate *every* combination of the values of the arrays. and i don't know how many times the term "string =" will appear. how do i do that in java?!
Re: reading file into a hashmap?
Are you just asking how to iterate over a Map? If so, check out the API- there is a method that returns a set that contains all of the keys, and there is a method that returns the mapped value of a key.
Re: reading file into a hashmap?
If you want to load a properties file like that have a look at Properties (Java Platform SE 6)
// Json