Java String Lower Case toLowerCase(String str)

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

Description

to Lower Case

License

Open Source License

Declaration

public static String toLowerCase(String str) 

Method Source Code

//package com.java2s;
/*/*from  w  w  w  .  j  a va 2 s .c o  m*/
 * JBoss, Home of Professional Open Source.
 *
 * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
 *
 * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
 */

public class Main {
    public static String toLowerCase(String str) {
        String newStr = convertBasicLatinToLower(str);
        if (newStr == null) {
            return str.toLowerCase();
        }
        return newStr;
    }

    private static String convertBasicLatinToLower(String str) {
        char[] chars = str.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            if (isBasicLatinUpperCase(chars[i])) {
                chars[i] = (char) ('a' + (chars[i] - 'A'));
            } else if (!isBasicLatinChar(chars[i])) {
                return null;
            }
        }
        return new String(chars);
    }

    private static boolean isBasicLatinUpperCase(char c) {
        return c >= 'A' && c <= 'Z';
    }

    private static boolean isBasicLatinChar(char c) {
        return c <= '\u007F';
    }
}

Related

  1. toLowerCase(String source)
  2. toLowerCase(String str)
  3. toLowerCase(String str)
  4. toLowerCase(String str)
  5. toLowerCase(String str)
  6. toLowerCase(String str)
  7. toLowerCase(String string)
  8. toLowerCase(String string)
  9. toLowerCase(String text)