public static String nextWord ( String string ) { int index = 0 ; while ( index < string . length ( ) && ! Character . isWhitespace ( string . charAt ( index ) ) ) { index ++ ; } return string . substring ( 0 , index ) ; }
Return the next word of the string in other words it stops when a space is encountered .