Java String Trim Right rightTrim(String src)

Here you can find the source of rightTrim(String src)

Description

right Trim

License

Apache License

Declaration

public static String rightTrim(String src) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static String rightTrim(String src) {
        if (src != null) {
            char[] chars = src.toCharArray();
            for (int i = chars.length - 1; i >= 0; i--) {
                if ((chars[i] != ' ') && (chars[i] != '\t') && (chars[i] != '\r')) {
                    return src.substring(0, i + 1);
                }//from   w w w. j a va  2 s .  co m
            }
            return "";
        }
        return src;
    }
}

Related

  1. rightTrim(final String aString)
  2. rightTrim(final String input, final char charToTrim)
  3. rightTrim(String input, char charToTrim)
  4. rightTrim(String s)
  5. rightTrim(String s, char c)
  6. rightTrim(String str)
  7. rightTrim(String str)
  8. rightTrim(String str)
  9. rightTrim(String string)