Java String Camel Case camelCase(final String value, final String delim)

Here you can find the source of camelCase(final String value, final String delim)

Description

converts string to camel case, using the specified string delimeter

License

Apache License

Declaration

public static String camelCase(final String value, final String delim) 

Method Source Code

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

public class Main {
    /**/* w  w  w  . j av  a  2s  .c  o  m*/
     * converts string to camel case, using the specified string delimeter
     */
    public static String camelCase(final String value, final String delim) {
        // check for null
        if (value == null || value.isEmpty()) {
            return "";
        }

        final StringBuilder result = new StringBuilder(value.length());
        final String[] parts = value.split(delim);
        if (parts != null && parts.length > 0) {
            boolean mustCapitalize = false;
            for (final String part : parts) {
                if (part.length() > 1) {
                    if (mustCapitalize) {
                        result.append(part.substring(0, 1).toUpperCase());
                        result.append(part.substring(1).toLowerCase());
                    } else {
                        result.append(part);
                        mustCapitalize = true;
                    }
                } else {
                    result.append(part);
                }
            }
        }

        return result.toString();
    }
}

Related

  1. camelCase(CharSequence... components)
  2. camelCase(final String input)
  3. camelCase(final String prefix, final String str)
  4. camelCase(final String text)
  5. camelCase(String column)
  6. camelCase(String content)
  7. camelCase(String in)
  8. camelCase(String in)