Read text file in java

后端 未结 5 2065
礼貌的吻别
礼貌的吻别 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:16

    The simplest way would be to read the whole file line by line once, parsing the lines as you go - then you can very easily get "all the IDs" followed by "all the first times" etc.

    If the file is too large to do that, you may want to consider writing a tool to change the file structure - open up several files for writing (one per column) then you can read an input line, write the output data to each file, move onto the next line etc. You can do this once and then read each file as and when you need it.

提交回复
热议问题