StringUtil { public static boolean trimEquals(String str1, String str2, boolean ignoreCase) { if (str1 == null) { return str2 == null; } if (str2 == null) { return false; } str1 = str1.trim(); str2 = str2.trim(); if (ignoreCase) { return str1.equalsIgnoreCase(str2); } return str1.equals(str2); }  static String subHead(String str, int maxLen); static String toString(Object obj); static String randomString(int length); static String join(String split, String... args); static String join(String split, Object... args); static String join(String split, Function<T, String> function, Collection<T> args); static String join(String split, Function<T, String> function, T ... args); static boolean isEmpty(String str); static String[] splitRemoveEmpty(String regex, String str); static boolean trimEquals(String str1, String str2, boolean ignoreCase); static boolean trimEquals(String str1, String str2); static String[] splitByLen(String buff, int splitLen); static int compareVersion(String version1, String version2); static String[] splitByLineRemoveEmpty(String str);  }
@Test public void testTrimEquals(){ Assert.assertTrue(StringUtil.trimEquals(" abc ", " abc \t")); Assert.assertFalse(StringUtil.trimEquals(null, " abc \t")); Assert.assertFalse(StringUtil.trimEquals("abc ", null)); }