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

StringleftAndRightTrim(String input, char charToTrim)
Removes the occurrences of the passed char in the start and end of the string.
return rightTrim(leftTrim(input, charToTrim), charToTrim);
intleftTrim(char[] text, int offset)
Return number of whitespace character from the offset to the first non whitespace character.
int counter = 0;
if (text != null && offset < text.length) {
    while (Character.isWhitespace(text[offset + counter])) {
        counter++;
return counter;
StringleftTrim(final String aString)
Copies this String removing white space characters from the beginning of the string.
if (aString == null) {
    return null;
int start = 0;
while ((start < aString.length()) && (aString.charAt(start) <= ' ')) {
    start++;
if (start == 0) {
...
StringleftTrim(final String input)
Get a version of a String with all leading whitespace removed.
if (input == null) {
    return null;
final int len = input.length();
int beginIndex = 0;
for (int i = 0; i < len; i++) {
    if (Character.isWhitespace(input.charAt(i))) {
        ++beginIndex;
...
StringleftTrim(final String input, final char charToTrim)
Removes the occurrences of the passed char in the end of the string.
final int len = input.length();
int off = 0;
final char[] val = input.toCharArray();
while (off < len && val[off] == charToTrim) {
    off++;
return input.substring(off, len);
StringleftTrim(String input, char charToTrim)
Removes the occurrences of the passed char in the end of the string.
int len = input.length();
int off = 0;
char[] val = input.toCharArray();
while ((off < len) && (val[off] == charToTrim)) {
    off++;
return input.substring(off, len);
StringleftTrim(String rawString)
left Trim
int firstNonSpace = 0;
for (int i = 0; i < rawString.length(); i++) {
    final char ch = rawString.charAt(i);
    if (ch > 32) {
        break;
    firstNonSpace++;
return rawString.substring(firstNonSpace);
StringleftTrim(String str)
left Trim
if (isEmpty(str))
    return str;
char[] charArray = str.toCharArray();
int length = charArray.length;
int start = 0;
while ((start < length) && (charArray[start] <= ' '))
    start++;
return str.substring(start);
...
Stringlefttrim(String str)
Removes all spaces from a string
String newString = str;
for (int i = 0; i < newString.length(); i++) {
    if (newString.charAt(i) != ' ') {
        newString = newString.substring(i);
        break;
return newString;
...
StringleftTrim(String str)
Removes leading whitespaces.
if (str.length() == 0) {
    return str;
int i = 0;
while (i < str.length()) {
    char c = str.charAt(i);
    if (Character.isWhitespace(c)) {
        i++;
...