I am reading a large file from disk. That file just contains numbers, encoded as plain old ASCII. At the moment, I am reading in chunks, and then doing something like this:
byte[] token; // bytes representing a bunch of numbers
int n = Integer.parseInt(new String(token));
In other words, I am converting to a String and then parsing the String to Integer. I would like to know if there is a way to use fast operations like shifting and binary arithmetic instead?
I suspect that this could be made faster. For example, the raw bytes for the numbers 1,2,3 are 49,50,51. Any ideas for hacks?