protected List < String > parseWords ( String line ) { List < String > words = new ArrayList < String > ( ) ; boolean insideWord = ! isSpace ( line . charAt ( 0 ) ) ; int last = 0 ; for ( int i = 0 ; i < line . length ( ) ; i ++ ) { char c = line . charAt ( i ) ; if ( insideWord ) { // see if its at the end of a word if ( isSpace ( c ) ) { words . add ( line . substring ( last , i ) ) ; insideWord = false ; } } else { if ( ! isSpace ( c ) ) { last = i ; insideWord = true ; } } } // if the line ended add the final word if ( insideWord ) { words . add ( line . substring ( last ) ) ; } return words ; }
Extracts the words from a string . Words are seperated by a space character .