Java tutorial
//package com.java2s; public class Main { /** * right trime character * @param p_str * @param p_match trim out this pattern * @return */ public static String rtrim(String p_str, char p_match) { int i = p_str.length(); for (; i > 0; i--) if (p_str.charAt(i - 1) != p_match) break; return p_str.substring(0, i); } }