public String [ ] tokenise ( String string ) { String str = string ; if ( str == null || str . length ( ) == 0 ) { return null ; } List < String > list = new ArrayList < String > ( ) ; int length = delimiter . length ( ) ; int idx = str . indexOf ( delimiter ) ; while ( idx != - 1 ) { String token = str . substring ( 0 , idx ) ; str = str . substring ( idx + length ) ; if ( trimTokens ) { token = token . trim ( ) ; } if ( ! skimEmpty || token . length ( ) > 0 ) { list . add ( token ) ; } idx = str . indexOf ( delimiter ) ; } // handle the case where there is only one token // or there is a token after the last separator if ( str . trim ( ) . length ( ) > 0 ) { if ( trimTokens ) { str = str . trim ( ) ; } list . add ( str ) ; } String [ ] tokens = new String [ list . size ( ) ] ; list . toArray ( tokens ) ; return tokens ; }
Tokenises the input string using the given delimiter .