/** * Word wrap a string where the line size for the first line is different * than the lines sizes for the other lines. * * @param str * @param firstLineSize * @param nonFirstLineSize * @return */ public static String[] wordWrap(String str, int firstLineSize, int nonFirstLineSize) { String[] lines = wordWrap(str, firstLineSize); if (lines.length > 1 && firstLineSize != nonFirstLineSize) { // More than one line. Re-wrap the non-first lines with the non // first line size String notFirstLinesString = StringUtils.join(lines, " ", 1, lines.length); String[] nonFirstLines = wordWrap(notFirstLinesString, nonFirstLineSize); List<String> nonFirstLineCollection = Arrays.asList(nonFirstLines); ArrayList<String> allLines = new ArrayList<String>(); allLines.add(lines[0]); allLines.addAll(nonFirstLineCollection); lines = allLines.toArray(lines); } return lines; }