Java String Trim Right rtrim(String str)

Here you can find the source of rtrim(String str)

Description

rtrim

License

Open Source License

Declaration

public static String rtrim(String str) 

Method Source Code

//package com.java2s;

public class Main {

    public static String rtrim(String str) {
        return rtrim(str, " ");
    }//from www . j  av  a2s  . c o m

    public static String rtrim(String str, String remove) {
        if (str == null || str.length() == 0 || remove == null || remove.length() == 0) {
            return str;
        }

        while (str.endsWith(remove) && (str.length() - remove.length()) >= 0) {
            str = str.substring(0, str.length() - remove.length());
        }
        return str;
    }
}

Related

  1. rtrim(String source)
  2. rtrim(String src, char ch, int nLen)
  3. rtrim(String str)
  4. rtrim(String str)
  5. rtrim(String str)
  6. rtrim(String str)
  7. rTrim(String str)
  8. rtrim(String str)
  9. rTrim(String str)