Java examples for java.lang:String Camel Case
delimited To Camel Case
public class Main{ public static void main(String[] argv){ String string = "java2s.com"; String delimiter = "."; System.out.println(delimitedToCamelCase(string,delimiter)); }//from ww w .j av a 2 s. c o m public static String delimitedToCamelCase(final String string, final String delimiter) { if (string == null) { return null; } final StringBuilder stringBuilder = new StringBuilder( string.toLowerCase()); final int stringLength = stringBuilder.length(); final int delimiterLength = delimiter.length(); boolean lastCharactersWereDelimiter = false; for (int i = 0, l = stringLength - delimiterLength; i < l; ++i) { if (string.substring(i, i + delimiterLength).equals(delimiter)) { lastCharactersWereDelimiter = true; stringBuilder.delete(i, i + delimiterLength); --i; continue; } if (lastCharactersWereDelimiter) { stringBuilder.replace(i, i + 1, (stringBuilder.charAt(i) + "").toUpperCase()); } } return stringBuilder.toString(); } public static String delimitedToCamelCase(final String string, final char delimiter) { return StringUtil.delimitedToCamelCase(string, delimiter + ""); } }