Read text file in java

后端 未结 5 2097
礼貌的吻别
礼貌的吻别 2020-12-12 00:00

Hey, I need to read a textfile in java. The problem is that the file has the following format:

Id time1 time2 time3 ...
ID2 time1 time2 time3 ...
         


        
5条回答
  •  没有蜡笔的小新
    2020-12-12 00:24

    We can't read files column-by-column. Read the whole file into memory (FileReader of java.nio) and parse the content (String#split on each line) in a datastructure like

    Map>
    

    where the maps key is the id (ID, ID2, ..) and the value a simple list that contains all the time values.

提交回复
热议问题