Here you can find the source of capitalize(final String str, final char... delimiters)
public static String capitalize(final String str, final char... delimiters)
//package com.java2s; //License from project: Open Source License public class Main { public static String capitalize(final String str, final char... delimiters) { final int delimLen = delimiters == null ? -1 : delimiters.length; if (isEmpty(str) || delimLen == 0) { return str; }//from ww w. j a v a2 s .c o m final char[] buffer = str.toCharArray(); boolean capitalizeNext = true; for (int i = 0; i < buffer.length; i++) { final char ch = buffer[i]; if (isDelimiter(ch, delimiters)) { capitalizeNext = true; } else if (capitalizeNext) { buffer[i] = Character.toTitleCase(ch); capitalizeNext = false; } } return new String(buffer); } public static boolean isEmpty(final CharSequence cs) { return cs == null || cs.length() == 0; } private static boolean isDelimiter(final char ch, final char[] delimiters) { if (delimiters == null) { return Character.isWhitespace(ch); } for (final char delimiter : delimiters) { if (ch == delimiter) { return true; } } return false; } }