display Name To Camel Case - Java java.lang

Java examples for java.lang:String Camel Case

Description

display Name To Camel Case

Demo Code

//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        String selectedChildTag = "asd asdf java2s.com";
        System.out.println(displayNameToCamelCase(selectedChildTag));
    }//w w  w.j  a va2s.co  m

    public static String displayNameToCamelCase(String selectedChildTag) {
        if (isNotEmptyWithTrim(selectedChildTag)) {
            StringBuilder builder = new StringBuilder("");
            for (int i = 0; i < selectedChildTag.length(); i++) {
                if (i == 0) {
                    builder.append((selectedChildTag.charAt(i) + "")
                            .toLowerCase());
                } else if (!Character.isSpaceChar(selectedChildTag
                        .charAt(i))) {
                    builder.append(selectedChildTag.charAt(i));
                }
            }
            return builder.toString();
        }
        return null;
    }

    public static boolean isNotEmptyWithTrim(String s) {
        return !isEmptyWithTrim(s);
    }

    public static boolean isEmptyWithTrim(String s) {
        return s == null || s.trim().length() == 0;
    }
}

Related Tutorials