I am looking for a library/API that seperates strings by spaces an line-breaks to appy sensible line wrapping to lines that exceed a given limit. For instance, if I set the Formatter I am looking for to column width 10 and add the following strings:
String s1 = "The quick brown fox jumped over the lazy dog.\n";
String s2 = "The quick\nbrown fox jumped over\nthe lazy dog.";
I expect output similar to:
The quick
brown fox
jumped
over the
lazy dog.
The quick
brown fox
jumped
over
the lazy
dog.
i.e. Line breaks already marked by the input text should be honoured and additional line-breaks schould be added when necessary.
Here is a quick and clumsy implementation by myself to illustrate a raw baseline of my expectations:
Column Formatter Whip-Up
Try the WordUtils.wrap(String, int) method from the Apache commons-lang library.