(String str)
| 7 | |
| 8 | public class WordUtil { |
| 9 | public static String capitalize(String str) { |
| 10 | if (StringUtils.isEmpty(str)) { |
| 11 | return str; |
| 12 | } |
| 13 | final char[] buffer = str.toCharArray(); |
| 14 | boolean capitalizeNext = true; |
| 15 | for (int i = 0; i < buffer.length; i++) { |
| 16 | final char ch = buffer[i]; |
| 17 | if (Character.isWhitespace(ch)) { |
| 18 | capitalizeNext = true; |
| 19 | } else if (capitalizeNext) { |
| 20 | buffer[i] = Character.toTitleCase(ch); |
| 21 | capitalizeNext = false; |
| 22 | } |
| 23 | } |
| 24 | return new String(buffer); |
| 25 | } |
| 26 | |
| 27 | private final static Pattern patternToWrapOn = Pattern.compile(" "); |
| 28 | public static String wordWrapAsHTML(String str) { |
no test coverage detected