Java Utililty Methods String Camel Case Format

List of utility methods to do String Camel Case Format

Description

The list of methods to do String Camel Case Format are organized into topic(s).

Method

StringtoCamelCase(final String identifier, boolean capital)
to Camel Case
if (identifier == null)
    return null;
StringBuilder sb = new StringBuilder(identifier);
if (sb.length() == 0)
    return "";
int i = 0;
while (i < sb.length()) {
    if (sb.charAt(i) == '_') {
...
StringtoCamelCase(final String init)
to Camel Case
if (init == null)
    return null;
final StringBuilder ret = new StringBuilder(init.length());
for (final String word : init.split("_")) {
    if (!word.isEmpty()) {
        if (word.equalsIgnoreCase("DW")) {
            ret.append("DW");
        } else {
...
StringtoCamelCase(final String input, final char spacer)
Converts a given String to camelCase AbcDef You can choose a character as "spacer" character, e.g.
if (input == null) {
    return null;
if (input.isEmpty()) {
    return "";
final StringBuilder stringBuilder = new StringBuilder();
for (final String subString : input.split(Character.toString(spacer))) {
...
StringtoCamelCase(final String inputString, boolean avoidFirst)
Replaces the white spaces and the "-" and transform the String in camel case
if (inputString == null)
    return null;
final StringBuilder ret = new StringBuilder(inputString.length());
for (final String word : inputString.replaceAll("_", " ").split("[ -]")) {
    if (avoidFirst) {
        ret.append(word.toLowerCase());
        avoidFirst = false;
        continue;
...
StringtoCamelCase(final String string)
CamelCases a 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;
...
StringtoCamelcase(final String string)
to Camelcase
StringBuilder s = new StringBuilder();
boolean big = false;
for (int i = 0; i < string.length(); i++) {
    char c = string.charAt(i);
    if ('_' == c) {
        big = true;
    } else {
        if (big) {
...
StringtoCamelCase(final String string)
to Camel Case
final char[] chars = string.toCharArray();
for (int i = 0; i < chars.length; i++) {
    final char c = chars[i];
    if (Character.isUpperCase(c)) {
        if (i > 0 && i < chars.length - 1 && Character.isLowerCase(chars[i + 1])) {
            break;
        } else {
            chars[i] = Character.toLowerCase(c);
...
StringtoCamelCase(String anyCase, char wordMarker)
to Camel Case
return toCamelCase(anyCase, wordMarker, true);
StringtoCamelCase(String argString)
Convert to camel-case string.
String[] parts = argString.split(" ");
String camelCaseString = "";
for (String part : parts) {
    String first = part.substring(0, 0).toUpperCase();
    String rest = "";
    if (part.length() > 1) {
        rest = part.substring(1, part.length() - 1);
    String space = " ";
    if (camelCaseString.isEmpty()) {
        space = "";
    camelCaseString += space + first + rest;
return camelCaseString;
StringtoCamelCase(String begin, String... parts)
to Camel Case
String name = begin.length() > 0 ? Character.toLowerCase(begin.charAt(0)) + begin.substring(1) : begin;
for (String part : parts) {
    name += Character.toUpperCase(part.charAt(0)) + part.substring(1);
return name;