X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2FStringUtils.java;h=fa72a4e83e14ee56f51e702056e7a5972345f72d;hb=c48600a5014b89ffec8a46cd20da3466e0c82c56;hp=f7548aecca717c19aff3b0c60db338f5ad0fe1df;hpb=5221cf7f72655a6e27af81167a4a3f237750c7ca;p=fanfix.git diff --git a/src/be/nikiroo/utils/StringUtils.java b/src/be/nikiroo/utils/StringUtils.java index f7548ae..fa72a4e 100644 --- a/src/be/nikiroo/utils/StringUtils.java +++ b/src/be/nikiroo/utils/StringUtils.java @@ -156,6 +156,30 @@ public class StringUtils { return text; } + /** + * Justify a text into width-sized (at the maximum) lines and return all the + * lines concatenated into a single '\\n'-separated line of text. + * + * @param text + * the {@link String} to justify + * @param width + * the maximum size of the resulting lines + * + * @return a list of justified text lines concatenated into a single + * '\\n'-separated line of text + */ + static public String justifyTexts(String text, int width) { + StringBuilder builder = new StringBuilder(); + for (String line : justifyText(text, width, null)) { + if (builder.length() > 0) { + builder.append('\n'); + } + builder.append(line); + } + + return builder.toString(); + } + /** * Justify a text into width-sized (at the maximum) lines. *