Java String Camel Case Format toCamelCase(String s, boolean firstCharUppercase)

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

Description

to Camel Case

License

Open Source License

Declaration

public static String toCamelCase(String s, boolean firstCharUppercase) 

Method Source Code

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

public class Main {
    public static String toCamelCase(String s, boolean firstCharUppercase) {
        char[] cl = s.toCharArray();
        StringBuffer sb = new StringBuffer();
        boolean upper = firstCharUppercase;
        for (char ch : cl) {
            switch (ch) {
            case '_':
            case '?':
            case ';': // add anything to escape
                upper = true;//from   www  . ja  va  2s .com
                break;
            default:
                sb.append((char) (upper ? (ch >= 'a' && ch <= 'z' ? ch - 'a' + 'A' : ch) : ch));
                upper = false;
            }
        }
        return sb.toString();
    }

    public static String toCamelCase(String s) {
        if (s.toLowerCase().equals("id"))
            return "Id";
        return toCamelCase(s, true);
    }
}

Related

  1. toCamelCase(String s)
  2. toCamelCase(String s)
  3. toCamelCase(String s)
  4. toCamelCase(String s)
  5. toCamelCase(String s)
  6. toCamelCase(String s, Boolean firstUpper)
  7. toCamelCase(String s, String separator, boolean capitalizeFirstPart)
  8. toCamelCase(String start)
  9. toCamelCase(String str)