Java String Camel Case Format toCamelCase(String s)

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

Description

Convert a string from "_" delimited to lower camel case

License

Apache License

Parameter

Parameter Description
s a parameter

Declaration

public static String toCamelCase(String s) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//from  w ww . j  a va  2s. c o  m
     * Convert a string from "_" delimited to lower camel case
     * 
     * @param s
     * @return
     */
    public static String toCamelCase(String s) {
        String[] parts = s.split("_");
        StringBuilder sb = new StringBuilder();
        for (String part : parts) {
            if (sb.length() == 0)
                sb.append(part.toLowerCase());
            else
                sb.append(toProperCase(part));
        }
        return sb.toString();
    }

    public static String toProperCase(String s) {
        return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
    }
}

Related

  1. toCamelCase(String origString)
  2. toCamelCase(String s)
  3. toCamelCase(String s)
  4. toCamelCase(String s)
  5. toCamelCase(String s)
  6. toCamelCase(String s)
  7. toCamelCase(String s)
  8. toCamelCase(String s)
  9. toCamelCase(String s)