### Question:
StringUtil { public static String trimWhitespace(String text) { if (isNullOrEmpty(text)) { return text; } char[] chars = text.toCharArray(); int start = 0; int end = chars.length; while ((start < end) && (Character.isWhitespace(chars[start]))) { start++; } while ((start < end) && (Character.isWhitespace(chars[end - 1]))) { end--; } if (start < end) { return ((start > 0) || (end < chars.length)) ? new String(chars, start, end - start) : text; } return ""; }  @SuppressWarnings("CStyleArrayDeclaration") static String capitalize(String text); @SuppressWarnings("CStyleArrayDeclaration") static String decapitalize(String text); static String fromSnakeCaseToCamelCase(String text); static String fromCamelCaseToSnakeCase(String text); static String fromCamelCaseToSnakeCaseWithLenient(String text); static boolean isWhitespace(String text); static String trimWhitespace(String text);  }### Answer:
@Test public void testTrimWhitespace() { assertEquals("aaa", StringUtil.trimWhitespace(" aaa ")); assertEquals("aaa", StringUtil.trimWhitespace("aaa ")); assertEquals("aaa", StringUtil.trimWhitespace("\raaa\n\t")); assertEquals("aaa", StringUtil.trimWhitespace("aaa")); }