Read large amount of data from file in Java

后端 未结 7 1334
一生所求
一生所求 2020-12-03 01:36

I\'ve got text file that contains 1 000 002 numbers in following formation:

123 456
1 2 3 4 5 6 .... 999999 100000

Now I need

7条回答
  •  天命终不由人
    2020-12-03 02:06

    It it's possible to reformat the input so that each integer is on a separate line (instead of one long line with one million integers), you should be seeing much improved performance using Integer.parseInt(BufferedReader.readLine()) due to smarter buffering by line and not having to split the long string into a separate array of Strings.

    Edit: I tested this and managed to read the output produced by seq 1 1000000 into an array of int well under half a second, but of course this depends on the machine.

提交回复
热议问题