Possible Duplicate:
Read large amount of data from file in Java
I have a string like "2 -56 0 78 0 4568 -89..." end so on. Now I use Scanner.nextInt() to parse it, but it seems to be slow. Platform is Android. Any advices how to implement in for better speed?
Thanks.
use myString.split(" "), which split on ' ', then Integer.valuesOf(..)
Split the string on the space and parse each entry
for (String s: string.split(" ")) {
int i = Integer.parseInt(s);
//do something with i
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With