Here you can find the source of uncapitalize(String str)
Parameter | Description |
---|---|
str | The String to be uncapitalized |
public static String uncapitalize(String str)
//package com.java2s; /*/* w w w . j a va 2 s . c om*/ * Copyright 2008-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Uncapitalizes a String (makes the first char lowercase) taking care * of blank strings and single character strings. * * @param str The String to be uncapitalized * @return Uncapitalized version of the target string if it is not blank */ public static String uncapitalize(String str) { if (isBlank(str)) return str; if (str.length() == 1) return String.valueOf(Character.toLowerCase(str.charAt(0))); return Character.toLowerCase(str.charAt(0)) + str.substring(1); } /** * <p>Determines whether a given string is <code>null</code>, empty, * or only contains whitespace. If it contains anything other than * whitespace then the string is not considered to be blank and the * method returns <code>false</code>.</p> * <p>We could use Commons Lang for this, but we don't want GriffonNameUtils * to have a dependency on any external library to minimise the number of * dependencies required to bootstrap Griffon.</p> * * @param str The string to test. * @return <code>true</code> if the string is <code>null</code>, or * blank. */ public static boolean isBlank(String str) { if (str == null || str.length() == 0) { return true; } for (char c : str.toCharArray()) { if (!Character.isWhitespace(c)) { return false; } } return true; } }