Java String Camel Case To camelToFixedString(String str, String fixed)

Here you can find the source of camelToFixedString(String str, String fixed)

Description

camel To Fixed String

License

Apache License

Declaration

public static String camelToFixedString(String str, String fixed) 

Method Source Code

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

public class Main {
    public static final String EMPTY = "";

    public static String camelToFixedString(String str, String fixed) {
        str = trimToEmpty(str);/*w  w w. j a  va 2s . c  om*/
        if (isEmpty(str)) {
            return str;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < str.length(); ++i) {
            char c = str.charAt(i);
            if (Character.isUpperCase(c)) {
                if (i != 0) {
                    sb.append(fixed);
                }
                sb.append(Character.toLowerCase(c));
            } else {
                sb.append(c);
            }
        }
        return sb.toString();
    }

    public static String trimToEmpty(String input) {
        if (input == null) {
            return EMPTY;
        }
        return input.trim();
    }

    public static boolean isEmpty(String s) {
        if (s == null || s.length() == 0) {
            return true;
        }
        return false;
    }
}

Related

  1. camelHumpsToWords(String camelHumps)
  2. camelhumpToUnderline(String str)
  3. camelizeOneWord(String word, boolean firstLetterInLowerCase)
  4. camelPrefix(String str, int prefixSize)
  5. camelToComposite(String camel)
  6. camelToLisp(final String pString)
  7. camelToLowerSnake(String camel)
  8. camelToPeriod(String value)
  9. camelToSplitName(String camelName, String split)