Java String Trim Right rightTrim(final String input, final char charToTrim)

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

Description

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

License

Common Public License

Declaration

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

Method Source Code

//package com.java2s;
/*//w  w  w  .j a va  2  s .  c  o  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 beggining of the
     * string.
     */
    public static String rightTrim(final String input, final char charToTrim) {
        int len = input.length();
        final int st = 0;
        final int off = 0;
        final char[] val = input.toCharArray();

        while (st < len && val[off + len - 1] == charToTrim) {
            len--;
        }
        return input.substring(0, len);
    }
}

Related

  1. rightTrim(final String aString)
  2. rightTrim(String input, char charToTrim)
  3. rightTrim(String s)
  4. rightTrim(String s, char c)
  5. rightTrim(String src)