Java String Camel Case To camelToSplitName(String camelName, String split)

Here you can find the source of camelToSplitName(String camelName, String split)

Description

camel To Split Name

License

Open Source License

Declaration

public static String camelToSplitName(String camelName, String split) 

Method Source Code

//package com.java2s;
/*/*from   ww w .java  2  s. com*/
 * Copyright 2009-2012 Evun Technology. 
 * 
 * This software is the confidential and proprietary information of
 * Evun Technology. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with evun.cn.
 */

public class Main {

    public static String camelToSplitName(String camelName, String split) {
        if (camelName == null || camelName.length() == 0) {
            return camelName;
        }
        StringBuilder buf = null;
        for (int i = 0; i < camelName.length(); i++) {
            char ch = camelName.charAt(i);
            if (ch >= 'A' && ch <= 'Z') {
                if (buf == null) {
                    buf = new StringBuilder();
                    if (i > 0) {
                        buf.append(camelName.substring(0, i));
                    }
                }
                if (i > 0) {
                    buf.append(split);
                }
                buf.append(Character.toLowerCase(ch));
            } else if (buf != null) {
                buf.append(ch);
            }
        }
        return buf == null ? camelName : buf.toString();
    }
}

Related

  1. camelToComposite(String camel)
  2. camelToFixedString(String str, String fixed)
  3. camelToLisp(final String pString)
  4. camelToLowerSnake(String camel)
  5. camelToPeriod(String value)
  6. camelToSql(String name)
  7. camelToWords(String camel)
  8. camelToXmlCase(String s)
  9. camelUp(String name)