Here you can find the source of camelCaseToPretty(String camelCase)
public static String camelCaseToPretty(String camelCase)
//package com.java2s; /*/*from www . j a v a 2 s. c om*/ * This software is in the public domain under CC0 1.0 Universal plus a * Grant of Patent License. * * To the extent possible under law, the author(s) have dedicated all * copyright and related and neighboring rights to this software to the * public domain worldwide. This software is distributed without any * warranty. * * You should have received a copy of the CC0 Public Domain Dedication * along with this software (see the LICENSE.md file). If not, see * <http://creativecommons.org/publicdomain/zero/1.0/>. */ public class Main { public static String camelCaseToPretty(String camelCase) { if (camelCase == null || camelCase.length() == 0) return ""; StringBuilder prettyName = new StringBuilder(); String lastPart = null; for (String part : camelCase.split("(?=[A-Z0-9\\.#])")) { if (part.length() == 0) continue; char firstChar = part.charAt(0); if (firstChar == '.' || firstChar == '#') { if (part.length() == 1) continue; part = part.substring(1); firstChar = part.charAt(0); } if (Character.isLowerCase(firstChar)) part = Character.toUpperCase(firstChar) + part.substring(1); if (part.equalsIgnoreCase("id")) part = "ID"; if (part.equals(lastPart)) continue; lastPart = part; if (prettyName.length() > 0) prettyName.append(" "); prettyName.append(part); } return prettyName.toString(); } }