camelify string - Android java.lang

Android examples for java.lang:String Case

Description

camelify string

Demo Code

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static String camelify(String original) {
        if (original == null)
            return "";
        StringBuilder builder = new StringBuilder();
        Pattern p = Pattern.compile("[a-zA-Z0-9]+");
        Matcher m = p.matcher(original);
        String word;/*from   www. ja  v a  2s .  c om*/
        while (m.find()) {
            word = m.group();
            builder.append(capitalize(word));
        }
        return builder.toString();
    }

}

Related Tutorials