private String wrapMessage ( final String message ) { // Note that the original cowsay wraps lines mid-word. // This version differs in that it wraps between words if possible. int wrap = getWordwrap ( ) ; if ( wrap <= 0 ) { return message ; } final List < String > result = new ArrayList < String > ( ) ; String newLine = System . getProperty ( "line.separator" ) ; String [ ] lines = message . split ( newLine ) ; for ( String line : lines ) { result . add ( WordUtils . wrap ( line , wrap , null , true ) ) ; } return StringUtils . join ( result , newLine ) ; }
Applies word wrapping to the message to handle long lines .