WhitespaceTrimmer { public static String trim(String text) { return (rtrim(ltrim(text.trim()))).trim(); } private  WhitespaceTrimmer(); static String trim(String text);  }
@Test public void testTrim() throws IOException { assertEquals("noTrim", WhitespaceTrimmer.trim("noTrim")); assertEquals("noEmbedded Trim", WhitespaceTrimmer.trim("noEmbedded Trim")); assertEquals("rightTrim", WhitespaceTrimmer.trim("rightTrim ")); assertEquals("leftTrim", WhitespaceTrimmer.trim(" leftTrim")); assertEquals("rightTrimAndLeftTrim", WhitespaceTrimmer.trim(" rightTrimAndLeftTrim ")); assertEquals("rightTrimAndLeftTrim", WhitespaceTrimmer.trim("\nrightTrimAndLeftTrim\n")); assertEquals("rightTrimAndLeftTrim", WhitespaceTrimmer.trim("\trightTrimAndLeftTrim\t")); }