Here you can find the source of rtrim(String s)
Parameter | Description |
---|---|
s | the string to rtrim. |
public static String rtrim(String s)
//package com.java2s; public class Main { /**//from w ww .j a va 2s. c o m * Right trims a string. * @param s the string to rtrim. * @return a trimmed string. */ public static String rtrim(String s) { if (s == null) return null; for (int k = s.length() - 1; k >= 0; k--) { if (!Character.isWhitespace(s.charAt(k))) return (k == s.length() - 1 ? s : s.substring(0, k + 1)); } return ""; } }