I have a long string of numbers,
String strNumbers = "123456789";
I need to get an int[]
from this.
I use this method to get it:
public static int[] getIntArray(strNumbers)
{
String[] strValues = strNumbers.split("");
int[] iArr = new int[strValues.length];
for(int i = 0; i < strValues.length; i++)
{
iArr[i] = Integer.parseInt(strValues[i]);
}
return iArr;
}
I get this error : java.lang.NumberFormatException: For input string: ""
My guess is that I cannot split a String that way. I tried all sorts of escape or Regex but nothing works.
Can anyone help?