Here you can find the source of toCamelCase(String inputString)
public static String toCamelCase(String inputString)
//package com.java2s; //License from project: Open Source License public class Main { public static String toCamelCase(String inputString) { String result = ""; if (inputString.length() == 0) { return result; }//from w w w . j a va 2s. co m char firstChar = inputString.charAt(0); char firstCharToUpperCase = Character.toUpperCase(firstChar); result = result + firstCharToUpperCase; for (int i = 1; i < inputString.length(); i++) { char currentChar = inputString.charAt(i); char previousChar = inputString.charAt(i - 1); if (previousChar == ' ') { char currentCharToUpperCase = Character.toUpperCase(currentChar); result = result + currentCharToUpperCase; } else { char currentCharToLowerCase = Character.toLowerCase(currentChar); result = result + currentCharToLowerCase; } } return result; } }