Java String Camel Case Format toCamelCase(String input, boolean firstCharUppercase, char separator)

Here you can find the source of toCamelCase(String input, boolean firstCharUppercase, char separator)

Description

to Camel Case

License

Open Source License

Parameter

Parameter Description
input a parameter
firstCharUppercase a parameter
separator a parameter

Declaration

public static String toCamelCase(String input, boolean firstCharUppercase, char separator) 

Method Source Code

//package com.java2s;
/*//from ww  w.j av  a 2 s .  co m
 * Copyright 2005-2020 GreenTube Team All rights reserved.
 * Support: Huxg
 * License: CND team license
 */

public class Main {
    /**
     * 
     * @param input
     * @param firstCharUppercase
     * @param separator
     * @return
     */
    public static String toCamelCase(String input, boolean firstCharUppercase, char separator) {
        int length = input.length();
        StringBuilder sb = new StringBuilder(length);
        boolean upperCase = firstCharUppercase;

        for (int i = 0; i < length; i++) {
            char ch = input.charAt(i);
            if (ch == separator) {
                upperCase = true;
            } else if (upperCase) {
                sb.append(Character.toUpperCase(ch));
                upperCase = false;
            } else {
                sb.append(ch);
            }
        }
        return sb.toString();
    }
}

Related

  1. toCamelCase(String in, boolean startWithUpper)
  2. toCamelCase(String input)
  3. toCamelCase(String input)
  4. toCamelCase(String input)
  5. toCamelCase(String input, boolean capitalizeFirsLetter)
  6. toCamelCase(String inputString)
  7. toCamelCase(String inputString)
  8. toCamelCase(String name)
  9. toCamelCase(String name)