Java String Trim Right rTrimObj(Object o)

Here you can find the source of rTrimObj(Object o)

Description

r Trim Obj

License

Apache License

Declaration

public static String rTrimObj(Object o) 

Method Source Code

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

public class Main {
    public static String rTrimObj(Object o) {
        return rTrim(nz(o));
    }//from  w w w. j  a va2s.com

    /**
     * Elimina gli spazi a dx della stringa
     */
    public static String rTrim(String s) {
        if (s == null) {
            return null;
        } else {
            char c[] = s.toCharArray();
            int i = s.length() - 1;
            while (i >= 0 && c[i] == ' ') {
                i--;
            }
            return s.substring(0, i + 1);
        }
    }

    public static String nz(Object o) {
        return o == null ? "" : o.toString();
    }
}

Related

  1. rtrim(String str, String suffixs)
  2. rtrim(String string, String end)
  3. rtrim(String text, char c)
  4. rTrim(String value)
  5. rtrim(String value, int maxLength)