Java String Camel Case Format toCamelCaseCapitalize(String underLineName)

Here you can find the source of toCamelCaseCapitalize(String underLineName)

Description

to Camel Case Capitalize

License

Open Source License

Declaration

public static String toCamelCaseCapitalize(String underLineName) 

Method Source Code

//package com.java2s;

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

    public static String toCamelCaseCapitalize(String underLineName) {
        if (underLineName == null) {
            return null;
        }/*  w w w .  ja  va 2s. c om*/
        underLineName = toCamelCase(underLineName);
        return underLineName.substring(0, 1).toUpperCase() + underLineName.substring(1);
    }

    public static String toCamelCase(String underLineName) {
        if (underLineName == null) {
            return null;
        }

        underLineName = underLineName.toLowerCase();

        StringBuilder sb = new StringBuilder(underLineName.length());
        boolean upperCase = false;
        for (int i = 0; i < underLineName.length(); i++) {
            char c = underLineName.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 value)
  2. toCamelCase(String value)
  3. toCamelCase(String value)
  4. toCamelCase(String value)
  5. toCamelCase(String value, String separator)
  6. toCamelCaseIdentifier(String formStr)
  7. toCamelCaseIgnoringLastChar(String string, String delimiter, boolean upperFirst)
  8. toCamelCasePresevingExisting(String s)
  9. toCamelCaseSimple(String str)