public static String[] getTokenArray( String string, int max, String delims )
   {
      StringTokenizer mst = new StringTokenizer( string, delims );
      int count = mst.countTokens();
      String[] ret;
      if( count <= max || max==0 ) {
         ret = new String[count];
         for( int i=0; i<count; i++ )
              ret[i]=mst.nextToken();
      } else {
         int i;
         ret = new String[max];
         for( i=0; i<max-1; i++ )
              ret[i]=mst.nextToken();
         ret[max-1]=mst.nextToken("");
         //remove initial delimiter from start of ret[max-1]
         char[] c=ret[max-1].toCharArray();
         for( i=0; i<c.length; i++ )
            if( delims.indexOf( c[i] )==-1 )
                break;
         if( i!=c.length )
            ret[max-1]=ret[max-1].substring( i );
      }

      return ret;
   }