Java String Trim Right rtrim(String s)

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

Description

rtrim

License

Apache License

Declaration

public static String rtrim(String s) 

Method Source Code

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

public class Main {

    public static String rtrim(String s) {
        int len = s.length();
        int st = 0;
        char[] val = s.toCharArray();

        while ((st < len) && (val[len - 1] <= ' ')) {
            len--;/*  w w w .  ja  v a 2 s . c  om*/
        }
        return (len < s.length()) ? s.substring(st, len) : s;
    }
}

Related

  1. rtrim(String s)
  2. rtrim(String s)
  3. rtrim(String s)
  4. rtrim(String s)
  5. rtrim(String s)
  6. rTrim(String s)
  7. rtrim(String s, char character)
  8. rtrim(String s, char character)
  9. rtrim(String s, Character c)