Java String Camel Case Format toCamelCase(final String string)

Here you can find the source of toCamelCase(final String string)

Description

to Camel Case

License

Apache License

Declaration

public static String toCamelCase(final String string) 

Method Source Code

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

public class Main {
    public static String toCamelCase(final String string) {
        final char[] chars = string.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            final char c = chars[i];
            if (Character.isUpperCase(c)) {
                // If we have moved beyond the first character, aren't yet at
                // the end and the next character is lower case then this must
                // be the first capital of the next word so don't lower case and
                // stop any further modification.
                if (i > 0 && i < chars.length - 1 && Character.isLowerCase(chars[i + 1])) {
                    break;
                } else {
                    chars[i] = Character.toLowerCase(c);
                }/*from  w w  w . j  a v  a  2  s.co m*/
            } else {
                break;
            }
        }
        return new String(chars);
    }
}

Related

  1. toCamelCase(final String identifier, boolean capital)
  2. toCamelCase(final String init)
  3. toCamelCase(final String input, final char spacer)
  4. toCamelCase(final String inputString, boolean avoidFirst)
  5. toCamelCase(final String string)
  6. toCamelcase(final String string)
  7. toCamelCase(String anyCase, char wordMarker)
  8. toCamelCase(String argString)