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

StringleftTrim(String string)
left Trim
if (string == null) {
    return "";
return string.replaceFirst("^\\s+", "");
StringleftTrim(String value)
left Trim
int count = 0;
while (Character.isWhitespace(value.charAt(count))) {
    count++;
return value.substring(count);
StringBuilderleftTrim(StringBuilder pStringBuilder)
Similar to the Perl chomp command.
while (true) {
    if (pStringBuilder.length() != 0 && Character.isWhitespace(pStringBuilder.charAt(0))) {
        pStringBuilder.deleteCharAt(0);
    } else {
        break;
return pStringBuilder;
...
StringleftTrimSlashes(String s)
Returns the specified string with all leading slashes removed.
while (s.startsWith("/")) {
    s = s.substring(1);
return s;
byte[]ltrim(byte[] a)
ltrim
if (a == null || a.length == 0) {
    return a;
int index = 0;
while (index < a.length && a[index] == 0) {
    index++;
if (index == 0) {
...
CharSequenceltrim(CharSequence str)
Trim horizontal whitespace from left side.
int len;
int i;
if (str == null || (len = str.length()) <= 0)
    return "";
for (i = 0; i < len; i++)
    if (!Character.isWhitespace(str.charAt(i)))
        break;
if (i >= len)
...
Stringltrim(final String str)
ltrim
int i;
int j;
int x = 0;
for (i = 0; i < str.length(); i++) {
    char ch = str.charAt(i);
    if (ch != ' ') {
        break;
final int len = (str.length() - i);
char[] res = new char[len];
for (j = i; j < str.length(); j++) {
    res[x++] = str.charAt(j);
return new String(res, 0, len);
Stringltrim(final String str, final char filler)
Performs left trim
if (str == null)
    return null;
for (int i = 0; i < str.length(); ++i) {
    if (str.charAt(i) != filler) {
        return str.substring(i);
return "";
...
Stringltrim(final String text)
ltrim
return ltrim(text, null);
StringlTrim(final String value)
Removes empty space from the beginning of a string
if (value == null) {
    return null;
String trimmed = value;
int offset = 0;
final int maxLength = value.length();
while (offset < maxLength && (value.charAt(offset) == ' ' || value.charAt(offset) == '\t')) {
    offset++;
...