Here you can find the source of toLowerCaseAscii(String s)
Parameter | Description |
---|---|
s | a string. |
public static String toLowerCaseAscii(String s)
//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(); } }