Java String Trim Left leftTrim(final String input, final char charToTrim)

Here you can find the source of leftTrim(final String input, final char charToTrim)

Description

Removes the occurrences of the passed char in the end of the string.

License

Common Public License

Declaration

public static String leftTrim(final String input, final char charToTrim) 

Method Source Code

//package com.java2s;
/*/*from  w  w  w . jav  a2  s  .co  m*/
 * @author Fabio Zadrozny
 * Created: June 2005
 * License: Common Public License v1.0
 */

public class Main {
    /**
     * Removes the occurrences of the passed char in the end of the string.
     */
    public static String leftTrim(final String input, final char charToTrim) {
        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);
    }
}

Related

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