Here you can find the source of toCamelCase(String value)
public static String toCamelCase(String value)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w ww .j a v a 2 s . co m*/ * Remove spaces, make each word start with uppercase. * CamelCase is a method for removing spaces from a phrase while maintaining leglibility. * * For example "Small molecule" -> "SmallMolecule" * "Show me your ID!" -> "ShowMeYourID!" * "Two spaces" -> "TwoSpaces" * " surrounded " -> "Surrounded" * Null-Safe: returns null if input is null; */ public static String toCamelCase(String value) { if (value == null) return null; StringBuilder result = new StringBuilder(); for (String word : value.trim().split(" +")) { result.append(word.substring(0, 1).toUpperCase()); result.append(word.substring(1)); } return result.toString(); } /** * Null-Safe version of String.toLowerCase; */ public static String toUpperCase(String input) { if (input == null) return null; return input.toUpperCase(); } }