Java String Lower Case toLowerCaseAscii(String s)

Here you can find the source of toLowerCaseAscii(String s)

Description

Returns a string with all ASCII upper-case letters converted to lower-case.

License

Creative Commons License

Parameter

Parameter Description
s a string.

Declaration

public static String toLowerCaseAscii(String s) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from  w  w  w  .ja  v a 2s. c  om*/
     * Returns a string with all ASCII upper-case letters
     * converted to lower-case.
     * 
     * @param s a string.
     */
    public static String toLowerCaseAscii(String s) {
        if (s == null)
            return null;
        int len = s.length();
        char c = 0;
        boolean hasUpperCase = false;
        for (int i = 0; i < len; i++) {
            c = s.charAt(i);
            if (c >= 'A' && c <= 'Z') {
                hasUpperCase = true;
                break;
            }
        }
        if (!hasUpperCase)
            return s;
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < len; i++) {
            c = s.charAt(i);
            if (c >= 'A' && c <= 'Z') {
                builder.append((char) (c + 0x20));
            } else {
                builder.append(c);
            }
        }
        return builder.toString();
    }
}

Related

  1. toLowerCase(String value)
  2. toLowerCase(String[] strArr)
  3. toLowerCase(StringBuffer buf)
  4. toLowerCase(StringBuffer buffer)
  5. toLowerCase0(String string)
  6. toLowerCaseFirst(String str)
  7. toLowerCaseFirst(String str)
  8. toLowerCaseFirst(String str)
  9. toLowerCaseFirst(String text)