code: public static String[] getTokens(String str, String delim, boolean trim){
          StringTokenizer stok = new StringTokenizer(str, delim);
          String tokens[] = new String[stok.countTokens()];
          for(int i=0; i<tokens.length; i++){
              tokens[i] = stok.nextToken();
              if(trim)
                  tokens[i] = tokens[i].trim();
          }
          return tokens;
      }
docs: Splits given string into tokens with delimiters specified.
  It uses StringTokenizer for tokenizing.
  
  @param str       string to be tokenized
  @param delim     delimiters used for tokenizing
  @param trim      trim the tokens
  
  @return non-null token array