Java Utililty Methods String Trim Left

List of utility methods to do String Trim Left

Description

The list of methods to do String Trim Left are organized into topic(s).

Method

Stringltrim(String str)
ltrim
if (!hasLength(str)) {
    return str;
StringBuilder sb = new StringBuilder(str);
while (sb.length() > 0 && Character.isWhitespace(sb.charAt(0))) {
    sb.deleteCharAt(0);
return sb.toString();
...
Stringltrim(String str)
ltrim
return ltrim(str, " ");
Stringltrim(String str)
ltrim
int index = 0;
while (' ' == str.charAt(index++))
    ;
if (index > 0)
    str = str.substring(index - 1);
return str;
Stringltrim(String str)
ltrim
int i = 0;
while (i < str.length()) {
    switch (str.charAt(i)) {
    case ' ':
    case '\t':
        i++;
        continue;
    break;
return str.substring(i);
Stringltrim(String str, String charList)
ltrim
int start = 0, len = str.length();
if (null == charList)
    for (int i = 0; i < len; i++)
        if (Character.isWhitespace(str.charAt(i)))
            start++;
        else
            break;
else
...
Stringltrim(String str, String defaultValue)
This function returns a string with whitespace stripped from the beginning of str
if (str == null)
    return defaultValue;
int len = str.length();
int st = 0;
while ((st < len) && (str.charAt(st) <= ' ')) {
    st++;
return ((st > 0)) ? str.substring(st) : str;
...
Stringltrim(String text, char c)
ltrim
if (text == null) {
    return EMPTY;
int i = 0;
int length = text.length();
while ((i < length) && (text.charAt(i) == c)) {
    i++;
return (i > 0 ? text.substring(i) : text);
intltrimCount(final String input)
ltrim Count
if (input == null)
    return 0;
if (input.isEmpty())
    return 0;
int i = 0;
while (i < input.length() && input.charAt(i) == ' ')
    ++i;
return i;
...
StringltrimNewline(String s)
Trims specified string from left and stop at \n character
if (s == null) {
    return null;
int index = 0;
int len = s.length();
while (index < len && Character.isWhitespace(s.charAt(index))) {
    if (s.charAt(index) == '\n') {
        break;
...
StringltrimZero(String inputString)
ltrim Zero
boolean findNonZero = false;
char paddingArr[] = inputString.trim().toCharArray();
StringBuffer sf = new StringBuffer();
for (int i = 0; i < paddingArr.length; i++) {
    if (!findNonZero) {
        sf.append(paddingArr[i]);
    } else if (findNonZero && (paddingArr[i] != '0')) {
        sf.append(paddingArr[i]);
...