Java String Camel Case Format toCamelCase(String s)

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

Description

to Camel Case

License

Open Source License

Declaration

public static String toCamelCase(String s) 

Method Source Code

//package com.java2s;

public class Main {
    private static final char SEPARATOR = '_';

    public static String toCamelCase(String s) {
        if (s == null) {
            return null;
        }//from   w  ww . jav  a 2s.  c om
        s = s.toLowerCase();
        StringBuilder sb = new StringBuilder(s.length());
        boolean upperCase = false;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == SEPARATOR) {
                upperCase = true;
            } else if (upperCase) {
                sb.append(Character.toUpperCase(c));
                upperCase = false;
            } else {
                sb.append(c);
            }
        }
        return sb.toString();
    }
}

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)
  7. toCamelCase(String s)
  8. toCamelCase(String s)
  9. toCamelCase(String s)