StringUtils { public static int parseIntDef(String s, int def) { try { return Integer.parseInt(s); } catch (NumberFormatException e) { return def; } } private  StringUtils(); static boolean endsWithIgnoreCase(String a, String b); static boolean matchesIgnoreCase(String a, String b, int posA); static boolean endsWithIgnoreCase(String a, char[] b); static boolean matchesIgnoreCase(String a, char[] b, int posA); static boolean endsWith(String a, char[] b); static boolean matches(String a, char[] b, int posA); static boolean startsWithIgnoreCase(String a, String b); static boolean equals(String s1, String s2, Locale locale); static boolean equals(String s1, String s2, boolean caseSensitive); static int parseIntDef(String s, int def); static String capitalize(String s); static String flatten(String s[]); static String flatten(String s[], String separator); static boolean isNullOrEmpty(String string); static final String EMPTY; }
@Test(dataProvider = "parseIntDef") public void testParseIntDef(String input, int def, int expected) { assert StringUtils.parseIntDef(input, def) == expected; }