Java String Trim Left ltrim(String s)

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

Description

Remove all leading blanks.

License

Open Source License

Parameter

Parameter Description
s the string to be processed

Return

the result of the processing

Declaration

public static String ltrim(String s) 

Method Source Code

//package com.java2s;

public class Main {
    /**//w  w w . j  a  va  2s. c o m
     * Remove all leading blanks.
     * @param s the string to be processed
     * @return the result of the processing
     */
    public static String ltrim(String s) {
        int index = 0;

        while (index < s.length() && isSpace(s.charAt(index)))
            index++;

        return s.substring(index, s.length());
    }

    /**
     * Check whether a character is a blank.
     * @param c the character to be checked
     * @return the result of the test
     */
    public static boolean isSpace(char c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t';
    }
}

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)
  7. ltrim(String s)
  8. ltrim(String s)
  9. ltrim(String s, char character)