WhitespaceTrimmer { static String rtrim(String text) { if (text == null) { return ""; } Matcher mEnd = whiteEnd.matcher(text); if (mEnd.find()) { int matchStart = mEnd.start(); return text.substring(0, matchStart); } else { return text; } } private  WhitespaceTrimmer(); static String trim(String text);  }
@Test public void testRTrim() throws IOException { assertEquals("noTrim", WhitespaceTrimmer.rtrim("noTrim")); assertEquals("noEmbedded Trim", WhitespaceTrimmer.rtrim("noEmbedded Trim")); assertEquals("rightTrim", WhitespaceTrimmer.rtrim("rightTrim ")); assertEquals("rightTrim", WhitespaceTrimmer.rtrim("rightTrim\n")); assertEquals("rightTrim", WhitespaceTrimmer.rtrim("rightTrim\t")); assertEquals(" noLeftTrim", WhitespaceTrimmer.rtrim(" noLeftTrim")); assertEquals(" rightTrimNoLeftTrim", WhitespaceTrimmer.rtrim(" rightTrimNoLeftTrim\n")); }