Java String Camel Case Format toCamelCase(String str)

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

Description

Convert a string to CamelCase

License

Open Source License

Parameter

Parameter Description
str a parameter

Declaration

public static String toCamelCase(String str) 

Method Source Code

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

public class Main {
    /**//ww w.  ja  va 2  s .com
     * Convert a string to CamelCase
     * @param str
     * @return
     */
    public static String toCamelCase(String str) {
        String[] wordList = str.toLowerCase().split("_");
        String finalStr = "";
        for (String word : wordList) {
            finalStr += capitalize(word);
        }
        return finalStr;
    }

    public static String capitalize(String line) {
        return Character.toUpperCase(line.charAt(0)) + line.substring(1);
    }
}

Related

  1. toCamelCase(String str)
  2. toCamelCase(String str)
  3. toCamelCase(String str)
  4. toCamelCase(String str)
  5. toCamelCase(String str)
  6. toCamelCase(String str, boolean firstCapital)
  7. toCamelCase(String string)
  8. toCamelCase(String string)
  9. toCamelCase(String string)