private static void flushCurrentWord ( StringBuilder currentWords , List < Word > formattedWords , boolean cutWhitespace ) { if ( currentWords . length ( ) > 0 ) { if ( cutWhitespace && currentWords . charAt ( currentWords . length ( ) - 1 ) == ' ' ) { currentWords . setLength ( currentWords . length ( ) - 1 ) ; } formattedWords . add ( new Word ( currentWords . toString ( ) ) ) ; currentWords . setLength ( 0 ) ; } }
Appends the accumulated words to the resulting words . Trailing whitespace is removed because of the postprocessing that inserts custom whitespace