static String [ ] tokenize ( String str ) { char sep = ' ' ; int start = 0 ; int len = str . length ( ) ; int count = 0 ; for ( int pos = 0 ; pos < len ; pos ++ ) { if ( str . charAt ( pos ) == sep ) { if ( pos != start ) { count ++ ; } start = pos + 1 ; } } if ( len != start ) { count ++ ; } String [ ] l = new String [ count ] ; count = 0 ; start = 0 ; for ( int pos = 0 ; pos < len ; pos ++ ) { if ( str . charAt ( pos ) == sep ) { if ( pos != start ) { String tok = str . substring ( start , pos ) ; l [ count ++ ] = tok ; } start = pos + 1 ; } } if ( len != start ) { String tok = str . substring ( start ) ; l [ count /* ++ */ ] = tok ; } return l ; }
Tokenize the the string as a package hierarchy