Java String Trim Left leftTrim(char[] text, int offset)

Here you can find the source of leftTrim(char[] text, int offset)

Description

Return number of whitespace character from the offset to the first non whitespace character.

License

Open Source License

Parameter

Parameter Description
text the scanned text
offset first character to inspect

Return

number of whitespaces or zero

Declaration

public static int leftTrim(char[] text, int offset) 

Method Source Code

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

public class Main {
    /**// w w  w.j  av  a 2s  .c  o m
     * Return number of whitespace character from the offset to the first non
     * whitespace character.
     *
     * @param text
     *            the scanned text
     *
     * @param offset
     *            first character to inspect
     *
     * @return number of whitespaces or zero
     */
    public static int leftTrim(char[] text, int offset) {
        int counter = 0;
        if (text != null && offset < text.length) {
            while (Character.isWhitespace(text[offset + counter])) {
                counter++;
            }
        }
        return counter;
    }
}

Related

  1. leftAndRightTrim(String input, char charToTrim)
  2. leftTrim(final String aString)
  3. leftTrim(final String input)
  4. leftTrim(final String input, final char charToTrim)
  5. leftTrim(String input, char charToTrim)