I'm trying to convert some strings from an array to integers using parseInt(). I am reading in lines from many separate files which look like this:
car,house,548544587,645871266
I have something like the code below:
String [] tokens = line.split(",");
try {
line = line.trim();
int a = Integer.parseInt(tokens[2]);
int b = Integer.parseInt(tokens[3]);
int c = (b - a);
System.out.println(c);
} catch (NumberFormatException e) {
System.out.println(e);
}
But this fails with errors like this, for each line I read in:
java.lang.NumberFormatException: For input string: "548544587"
java.lang.NumberFormatException: For input string: "645871266"
Any idea what I might be missing?