Convert CSV values to a HashMap key value pairs in JAVA

前端 未结 8 1026
刺人心
刺人心 2020-12-03 03:33

HI I have a csv called test.csv . I am trying to read the csv line by line and convert the values into a hash key value pairs . Here is the code :-



        
8条回答
  •  青春惊慌失措
    2020-12-03 04:23

    Beside the problem you have with the first number which its not a pair and its causing the Exception, you will not want to use Hashmap, since hashmap use a unique key, so line 2 will replace values from line 1.

    You should use a MultiMap, or a List of pairs in this case.

提交回复
热议问题