@Test public void uppercaseFirst() { assertThat(StringUtils.capitalize("foo"), equalTo("Foo")); assertThat(StringUtils.capitalize(" foo"), equalTo(" foo")); assertThat(StringUtils.capitalize("10-foo"), equalTo("10-foo")); assertThat(StringUtils.capitalize("_foo"), equalTo("_foo")); }
public static String capitalize(final String str) { if (str == null || str.length() == 0) { return str; } int firstCodepoint = str.codePointAt(0); int newCodePoint = Character.toTitleCase(firstCodepoint); if (firstCodepoint == newCodePoint) { return str; } int[] newCodePoints = new int[str.length()]; int outOffset = 0; newCodePoints[outOffset++] = newCodePoint; for (int inOffset = Character.charCount(firstCodepoint); inOffset < str.length();) { int codepoint = str.codePointAt(inOffset); newCodePoints[outOffset++] = codepoint; inOffset += Character.charCount(codepoint); } return new String(newCodePoints, 0, outOffset); }
StringUtils { public static String capitalize(final String str) { if (str == null || str.length() == 0) { return str; } int firstCodepoint = str.codePointAt(0); int newCodePoint = Character.toTitleCase(firstCodepoint); if (firstCodepoint == newCodePoint) { return str; } int[] newCodePoints = new int[str.length()]; int outOffset = 0; newCodePoints[outOffset++] = newCodePoint; for (int inOffset = Character.charCount(firstCodepoint); inOffset < str.length();) { int codepoint = str.codePointAt(inOffset); newCodePoints[outOffset++] = codepoint; inOffset += Character.charCount(codepoint); } return new String(newCodePoints, 0, outOffset); } }
StringUtils { public static String capitalize(final String str) { if (str == null || str.length() == 0) { return str; } int firstCodepoint = str.codePointAt(0); int newCodePoint = Character.toTitleCase(firstCodepoint); if (firstCodepoint == newCodePoint) { return str; } int[] newCodePoints = new int[str.length()]; int outOffset = 0; newCodePoints[outOffset++] = newCodePoint; for (int inOffset = Character.charCount(firstCodepoint); inOffset < str.length();) { int codepoint = str.codePointAt(inOffset); newCodePoints[outOffset++] = codepoint; inOffset += Character.charCount(codepoint); } return new String(newCodePoints, 0, outOffset); } private  StringUtils(); }
StringUtils { public static String capitalize(final String str) { if (str == null || str.length() == 0) { return str; } int firstCodepoint = str.codePointAt(0); int newCodePoint = Character.toTitleCase(firstCodepoint); if (firstCodepoint == newCodePoint) { return str; } int[] newCodePoints = new int[str.length()]; int outOffset = 0; newCodePoints[outOffset++] = newCodePoint; for (int inOffset = Character.charCount(firstCodepoint); inOffset < str.length();) { int codepoint = str.codePointAt(inOffset); newCodePoints[outOffset++] = codepoint; inOffset += Character.charCount(codepoint); } return new String(newCodePoints, 0, outOffset); } private  StringUtils(); static boolean isEmpty(final CharSequence cs); static boolean isBlank(final CharSequence cs); static boolean isNotBlank(final CharSequence cs); static String trim(final String str); static String trimToNull(final String str); static String trimToEmpty(final String str); static boolean equals(final String cs1, final String cs2); static String substring(final String str, int start); static String substring(final String str, int start, int end); static String upperCase(final String str); static String lowerCase(final String str); static String capitalize(final String str); static String uncapitalize(final String str); static boolean startsWithIgnoreCase(String str, String prefix); static String repeat(final String str, final int repeat); static String repeat(final char ch, final int repeat); static String rightPad(final String str, final int size); static String rightPad(final String str, final int size, final char padChar); static String rightPad(final String str, final int size, String padStr); static String leftPad(final String str, final int size); static String leftPad(final String str, final int size, final char padChar); static String leftPad(final String str, final int size, String padStr); static String strip(String str, final String stripChars); static String stripEnd(final String str, final String stripChars); static String stripStart(final String str, final String stripChars); static String stripToEmpty(final String str); static String wrap(final String str, final int wrapLength); static String wrap(final String str,
            final int wrapLength,
            final String newLineStr,
            final boolean wrapLongWords); static String wrap(final String str,
            int wrapLength,
            String newLineStr,
            final boolean wrapLongWords,
            String wrapOn); static String escapeJavaString(Object object, String indent); static int levenshteinDistance(CharSequence left, CharSequence right, final int threshold); }
StringUtils { public static String capitalize(final String str) { if (str == null || str.length() == 0) { return str; } int firstCodepoint = str.codePointAt(0); int newCodePoint = Character.toTitleCase(firstCodepoint); if (firstCodepoint == newCodePoint) { return str; } int[] newCodePoints = new int[str.length()]; int outOffset = 0; newCodePoints[outOffset++] = newCodePoint; for (int inOffset = Character.charCount(firstCodepoint); inOffset < str.length();) { int codepoint = str.codePointAt(inOffset); newCodePoints[outOffset++] = codepoint; inOffset += Character.charCount(codepoint); } return new String(newCodePoints, 0, outOffset); } private  StringUtils(); static boolean isEmpty(final CharSequence cs); static boolean isBlank(final CharSequence cs); static boolean isNotBlank(final CharSequence cs); static String trim(final String str); static String trimToNull(final String str); static String trimToEmpty(final String str); static boolean equals(final String cs1, final String cs2); static String substring(final String str, int start); static String substring(final String str, int start, int end); static String upperCase(final String str); static String lowerCase(final String str); static String capitalize(final String str); static String uncapitalize(final String str); static boolean startsWithIgnoreCase(String str, String prefix); static String repeat(final String str, final int repeat); static String repeat(final char ch, final int repeat); static String rightPad(final String str, final int size); static String rightPad(final String str, final int size, final char padChar); static String rightPad(final String str, final int size, String padStr); static String leftPad(final String str, final int size); static String leftPad(final String str, final int size, final char padChar); static String leftPad(final String str, final int size, String padStr); static String strip(String str, final String stripChars); static String stripEnd(final String str, final String stripChars); static String stripStart(final String str, final String stripChars); static String stripToEmpty(final String str); static String wrap(final String str, final int wrapLength); static String wrap(final String str,
            final int wrapLength,
            final String newLineStr,
            final boolean wrapLongWords); static String wrap(final String str,
            int wrapLength,
            String newLineStr,
            final boolean wrapLongWords,
            String wrapOn); static String escapeJavaString(Object object, String indent); static int levenshteinDistance(CharSequence left, CharSequence right, final int threshold);  }