public static String[] tokenize(String str, String delimiters, boolean trim) {
        if (str == null) {
            return new String[0];
        }
        StringTokenizer st = new StringTokenizer(str, delimiters);
        List<String> tokens = new ArrayList<>();
        while (st.hasMoreTokens()) {
            tokens.add(trim ? st.nextToken().trim() : st.nextToken());
        }
        return tokens.toArray(new String[0]);
    }
public static String [ ] tokenize ( String str , String delimiters , boolean trim ) { if ( str == null ) { return new String [ 0 ] ; } StringTokenizer st = new StringTokenizer ( str , delimiters ) ; List < String > tokens = new ArrayList < > ( ) ; while ( st . hasMoreTokens ( ) ) { tokens . add ( trim ? st . nextToken ( ) . trim ( ) : st . nextToken ( ) ) ; } return tokens . toArray ( new String [ 0 ] ) ; }
Tokenize the given {@code String} into a {@code String} array via a {@code StringTokenizer}.

@param str the String to tokenize
@param delimiters the delimiter characters
@param trim trim the tokens via String's trim
@return an array of the tokens