Convert String to camel Case To Words - Android java.lang

Android examples for java.lang:String Case

Description

Convert String to camel Case To Words

Demo Code

import java.util.List;
import java.util.Map;

public class Main{

    public static String camelCaseToWords(String string) {
        if (IsNullOrEmpty(string))
            return string;

        StringBuilder result = new StringBuilder(string.length());
        result.append(Character.toUpperCase(string.charAt(0)));

        for (int i = 1; i < string.length(); ++i) {
            char chr = string.charAt(i);
            if (Character.isUpperCase(chr)) {
                result.append(' ');
            }//from  w w w .  j a  v  a  2  s  .  c o m
            result.append(chr);
        }

        return result.toString();
    }

}

Related Tutorials