public static int[] splitInts(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;
}

public static int [ ] splitInts ( 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 ; }
parse comma - separated list of ints and return as array .
