public static int [ ] arrayFromStringOfIntegers ( String str ) throws IllegalArgumentException { StringTokenizer tokenizer = new StringTokenizer ( str , "," ) ; int n = tokenizer . countTokens ( ) ; int [ ] list = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { String token = tokenizer . nextToken ( ) ; list [ i ] = Integer . parseInt ( token ) ; } return list ; }
Split string of comma - delimited ints into an a int array