Java String Decamel Case decamelize(String s)

Here you can find the source of decamelize(String s)

Description

decamelize

License

Open Source License

Parameter

Parameter Description
s a parameter

Declaration

public static String decamelize(String s) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from w  w w .j  av  a2  s.c  om
     * 
     * @param s
     * @return
     */
    public static String decamelize(String s) {
        if (s == null || s.equals("")) {
            return s;
        }
        StringBuffer buf = new StringBuffer();
        buf.append(Character.toLowerCase(s.charAt(0)));
        for (int i = 1; i < s.length(); i++) {
            if (Character.isUpperCase(s.charAt(i))) {
                if (s.length() > i + 1 && Character.isLowerCase(s.charAt(i + 1))) {
                    buf.append("-");
                }
            }
            buf.append(Character.toLowerCase(s.charAt(i)));
        }
        return buf.toString();
    }
}

Related

  1. deCamelCase(String camelCased, String delim)
  2. deCamelCase(String identifier)
  3. deCamelCaseStyle(String style)
  4. decamelise(String testName)
  5. decamelize(final String s)
  6. deCamelize(String value)
  7. decamelizeAndReplaceByHyphen(String s)