Java String Camel Case Format toCamelCase(String argString)

Here you can find the source of toCamelCase(String argString)

Description

Convert to camel-case string.

License

Open Source License

Parameter

Parameter Description
argString a parameter

Declaration

public static String toCamelCase(String argString) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from ww  w . j a  v  a2s .  co  m
     * Convert to camel-case string.
     * 
     * @param argString
     * @return 
     */
    public static String toCamelCase(String argString) {
        String[] parts = argString.split(" ");
        String camelCaseString = "";
        for (String part : parts) {
            String first = part.substring(0, 0).toUpperCase();
            String rest = "";
            if (part.length() > 1) {
                rest = part.substring(1, part.length() - 1);
            }
            String space = " ";
            if (camelCaseString.isEmpty()) {
                space = "";
            }
            camelCaseString += space + first + rest;
        } // foreach
        return camelCaseString;
    }
}

Related

  1. toCamelCase(final String inputString, boolean avoidFirst)
  2. toCamelCase(final String string)
  3. toCamelcase(final String string)
  4. toCamelCase(final String string)
  5. toCamelCase(String anyCase, char wordMarker)
  6. toCamelCase(String begin, String... parts)
  7. toCamelCase(String columnName)
  8. toCamelCase(String dashCase)
  9. toCamelCase(String id)