private String getSentenceFromListCheckingNewLines ( List < String > strings ) { StringBuilder stringBuilder = new StringBuilder ( ) ; for ( String string : strings ) { stringBuilder . append ( string ) ; //We don't want to add a space next to the word if this one contains a new line character if ( ! string . contains ( "\n" ) && ! string . contains ( "\r" ) ) { stringBuilder . append ( NORMAL_SPACE ) ; } } return stringBuilder . toString ( ) ; }
Creates a string using the words in the list and adds spaces between words taking new lines in consideration .