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
Thanks for every answer but I've already found a method that meets my criteria:
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("./path"));
int n = readInt(bis);
int t = readInt(bis);
int array[] = new int[n];
for (int i = 0; i < n; i++) {
array[i] = readInt(bis);
}
private static int readInt(InputStream in) throws IOException {
int ret = 0;
boolean dig = false;
for (int c = 0; (c = in.read()) != -1; ) {
if (c >= '0' && c <= '9') {
dig = true;
ret = ret * 10 + c - '0';
} else if (dig) break;
}
return ret;
}
It requires only about 300 ms to read 1 mln of integers!