Java String Camel Case Format toCamelCase(final String string)

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

Description

CamelCases a String .

License

Open Source License

Declaration

public static String toCamelCase(final String string) 

Method Source Code

//package com.java2s;

public class Main {
    /**//  w  w  w .j a v a 2  s.  c o  m
     * CamelCases a {@link String}.
     */
    public static String toCamelCase(final String string) {
        if (string == null || string.length() == 0)
            return string;
        final StringBuilder builder = new StringBuilder();
        boolean upCase = true;
        for (char ch : string.toCharArray()) {
            if (Character.isLetterOrDigit(ch)) {
                builder.append(upCase ? Character.toUpperCase(ch) : Character.toLowerCase(ch));
                upCase = false;
            } else {
                upCase = true;
            }
        }
        return builder.toString();
    }
}

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)
  9. toCamelCase(String begin, String... parts)