Java String Trim Right rtrim(final String str)

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

Description

rtrim

License

Open Source License

Declaration

public static String rtrim(final String str) 

Method Source Code

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

public class Main {
    public static String rtrim(final String str) {
        int i, j;

        for (i = str.length() - 1; i >= 0; i--) {
            char ch = str.charAt(i);
            if (ch != ' ') {
                break;
            }/* ww w .j  a va 2s .  co  m*/
        }

        char[] res = new char[i + 1];

        for (j = 0; j <= i; j++) {
            res[j] = str.charAt(j);
        }
        return new String(res, 0, i + 1);
    }
}

Related

  1. rightTrimNewLineChars(String input)
  2. rightTrimSize(String s)
  3. rightTrimSlashes(String s)
  4. rightTrimString(String originalString)
  5. rtrim(final String input)
  6. rtrim(final String str, final char filler)
  7. rtrim(final String text)
  8. rTrim(final String value)
  9. rtrim(String input)