StringUtils { public static final String trimAll(String str) { if (str == null) { return str; } int len = str.length(); StringBuilder sb = new StringBuilder(len); for (int i = 0; i < len; i++) { char ch = str.charAt(i); switch (ch) { case ' ': case '\t': case '\r': case '\n': break; default: sb.append(ch); } } return sb.toString(); }  static final boolean isEmpty(String str); static final boolean isNotEmpty(String str); static final String join(String[] array, String separator); static final String join(Collection<String> list, String separator); static final String normalizeSpace(String str); static final String trimAll(String str);  }
@Test public void testTrimAll() { Assert.assertNull(StringUtils.trimAll(null)); Assert.assertEquals("foobar", StringUtils.trimAll(" f\to\ro\nb a r ")); }