I have a problem with my code. I read a couple of numbers of a text-file. For example: Textfile.txt
1, 21, 333
With my following code I wan
For folks who come here from a search, this function takes a separated values string and delimiter string and returns an integer array of extracted values.
int[] parseStringArr( String str, String delim ) {
String[] strArr = str.trim().split(delim);
int[] intArr = new int[strArr.length];
for (int i = 0; i < strArr.length; i++) {
String num = strArr[i].trim();
intArr[i] = Integer.parseInt(num);
}
return intArr;
}