Java String Capitalize capitalize(String str)

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

Description

capitalize

License

Open Source License

Declaration


public static String capitalize(String str) 

Method Source Code

//package com.java2s;
/*/*  w w w.jav a2s . c  o  m*/
 *  ?????? : ???? ???? ??? ??
 *  ??? : MOB ??? ???
 *
 *  Copyright 2007 by Digital Solution Center, Samsung Electronics, Inc.,
 *   All rights reserved.
 *
 *  This software is the confidential and proprietary information
 *  of Samsung Electronics, Inc. ("Confidential Information").  You
 *  shall not disclose such Confidential Information and shall use
 *  it only in accordance with the terms of the license agreement
 *  you entered into with Samsung.
 *
 *
 */

public class Main {

    public static String capitalize(String str) {
        int strLen;
        if (str == null || (strLen = str.length()) == 0) {
            return str;
        }
        return new StringBuffer(strLen).append(Character.toTitleCase(str.charAt(0))).append(str.substring(1))
                .toString();
    }

    public static String subString(String str, int offset, int leng) {
        return new String(str.getBytes(), (offset - 1), leng);
    }

    public static String subString(String str, int offset) {
        byte[] bytes = str.getBytes();
        int size = bytes.length - (offset - 1);
        return new String(bytes, (offset - 1), size);
    }
}

Related

  1. capitalize(String str)
  2. capitalize(String str)
  3. capitalize(String str)
  4. capitalize(String str)
  5. capitalize(String str)
  6. capitalize(String str)
  7. capitalize(String str)
  8. capitalize(String str)
  9. capitalize(String str)