Java String Capitalize capitalizeString(String str)

Here you can find the source of capitalizeString(String str)

Description

capitalize String

License

Open Source License

Declaration

public static String capitalizeString(String str) 

Method Source Code

//package com.java2s;
/**/*from  w  w  w . j  a  v  a2s  .co  m*/
 *  ETRI Distributed Resource/Mediation System for new re-generation Energy Exchange
 *
 *  Copyright ? [2016] ETRI. All rights reserved.
 *
 *    This is a proprietary software of ETRI, and you may not use this file except in
 *  compliance with license agreement with ETRI. Any redistribution or use of this
 *  software, with or without modification shall be strictly prohibited without prior written
 *  approval of ETRI, and the copyright notice above does not evidence any actual or
 *  intended publication of such software.
 *
 * com.nc.common.utils : StringUtil.java
 * @author creme55
 * @since 2016. 10. 12.
 * @version 1.0
 * @see 
 * @Copyright ? [2016] By ETRI. All rights reserved.
 *
 * <pre>
 * << ??????(Modification Information) >>
 *      ?????              ????                  ????
 *  -------------        -----------       -------------------------
 *  2016. 10. 12.          creme55         ?? ???(???? ?? ????)              
 *
 * </pre>
 **/

public class Main {

    public static String capitalizeString(String str) {
        int strLen;
        if (str == null || (strLen = str.length()) == 0) {
            return str;
        }
        StringBuffer buffer = new StringBuffer(strLen);
        boolean whitespace = true;
        for (int i = 0; i < strLen; i++) {
            char ch = str.charAt(i);
            if (Character.isWhitespace(ch)) {
                buffer.append(ch);
                whitespace = true;
            } else if (whitespace) {
                buffer.append(Character.toTitleCase(ch));
                whitespace = false;
            } else {
                buffer.append(ch);
            }
        }
        return buffer.toString();
    }

    public static boolean isWhitespace(String str) {
        if (str == null) {
            return false;
        }
        int sz = str.length();
        for (int i = 0; i < sz; i++) {
            if ((Character.isWhitespace(str.charAt(i)) == false)) {
                return false;
            }
        }
        return true;
    }

    public static String toString(int value) {
        return Integer.toString(value);
    }
}

Related

  1. capitalizePlayerName(String name)
  2. capitalizePropertyName(String propertyName)
  3. capitalizePropertyName(String s)
  4. capitalizeString(final String in)
  5. capitalizeString(String aString)
  6. capitalizeString(String string)
  7. capitalizeString(String string)
  8. capitalizeString(String string)
  9. capitalizeString(String text, boolean replaceUnderscore)