Here you can find the source of camelCase(String in)
public static String camelCase(String in)
//package com.java2s; // it under the terms of the GNU General Public License as published by public class Main { /**//from w w w . ja v a2s . c om * Camel case anY STRING given as InPuT.<br> * returns : <br> * CamelCaseAnyStringGivenAsInput. */ public static String camelCase(String in) { return removeWhiteSpaces(capitalize(in.toLowerCase(), true)); } public static String removeWhiteSpaces(String in) { return in.replaceAll("\\s+", ""); } /** * Capitalize the first letter of a text. Example : capitalize("toto") * returns "Toto" */ public static String capitalize(String in) { return capitalize(in, false); } /** * Capitalize all words in a text. Result is trimmed, and all sequences of * white characters are replaced by a regular space: " ". * * @param in * @param all * @return "toto tata" gives "Toto Tata" */ public static String capitalize(String in, boolean all) { if (in == null || in.equals("")) return in; if (!all) return in.substring(0, 1).toUpperCase() + in.substring(1); else { StringBuffer out = new StringBuffer(""); for (String word : in.split("\\s+")) { out.append(" ").append(capitalize(word)); } return out.toString().trim(); } } }