Java String Trim Left ltrim(String s)

Here you can find the source of ltrim(String s)

Description

Left trims a string.

License

Open Source License

Parameter

Parameter Description
s the string to ltrim.

Return

a trimmed string.

Declaration

public static String ltrim(String s) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from  w  ww .ja v  a  2 s .c o  m*/
     * Left trims a string.
     * @param s the string to ltrim.
     * @return a trimmed string.
     */
    public static String ltrim(String s) {
        if (s == null)
            return null;

        for (int k = 0; k < s.length(); k++) {
            if (!Character.isWhitespace(s.charAt(k)))
                return (k == 0 ? s : s.substring(k));
        }
        return "";
    }
}

Related

  1. lTrim(String s)
  2. ltrim(String s)
  3. ltrim(String s)
  4. ltrim(String s)
  5. ltrim(String s)
  6. ltrim(String s, char character)
  7. ltrim(String s, Character c)
  8. ltrim(String source)
  9. ltrim(String source)