Java examples for java.lang:String Camel Case
camel Case To Display Name
//package com.java2s; public class Main { public static void main(String[] argv) { String camelCase = "AbcDef java2s.com"; System.out.println(camelCaseToDisplayName(camelCase)); }/* w w w. j av a2 s.c om*/ public static String camelCaseToDisplayName(String camelCase) { if (isNotEmptyWithTrim(camelCase)) { StringBuilder builder = new StringBuilder(""); for (int i = 0; i < camelCase.length(); i++) { if (i == 0) { builder.append((camelCase.charAt(i) + "").toUpperCase()); } else if (Character.isUpperCase(camelCase.charAt(i))) { builder.append(" "); builder.append(camelCase.charAt(i)); } else { builder.append(camelCase.charAt(i)); } } return builder.toString(); } return ""; } public static boolean isNotEmptyWithTrim(String s) { return !isEmptyWithTrim(s); } public static boolean isEmptyWithTrim(String s) { return s == null || s.trim().length() == 0; } }