Java String Trim Left leftTrim(final String aString)

Here you can find the source of leftTrim(final String aString)

Description

Copies this String removing white space characters from the beginning of the string.

License

Open Source License

Parameter

Parameter Description
aString the String to trim.

Return

a new String with characters \\u0020 removed from the beginning

Declaration

public static String leftTrim(final String aString) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from  w ww.  j a  v  a 2s .  c o m*/
     * Copies this String removing white space characters from the beginning of the string.
     *
     * @param aString the String to trim.
     * @return a new String with characters <code>\\u0020</code> removed from the beginning
     */
    public static String leftTrim(final String aString) {
        if (aString == null) {
            return null;
        }
        int start = 0;
        while ((start < aString.length()) && (aString.charAt(start) <= ' ')) {
            start++;
        }
        if (start == 0) {
            return aString;
        }
        return aString.substring(start);
    }
}

Related

  1. leftAndRightTrim(String input, char charToTrim)
  2. leftTrim(char[] text, int offset)
  3. leftTrim(final String input)
  4. leftTrim(final String input, final char charToTrim)
  5. leftTrim(String input, char charToTrim)
  6. leftTrim(String rawString)