IniReader { public int getInt(String key, int defaultValue) { Optional<String> stringOptional = Optional.ofNullable(values.get(key)); try { return stringOptional.map(Integer::parseInt).orElse(defaultValue); } catch (NumberFormatException e) { return defaultValue; } } IniReader(String fileName, SolFileReader reader);  IniReader(BufferedReader reader); static void write(String fileName, Object... keysVals); String getString(String key, String defaultValue); int getInt(String key, int defaultValue); boolean getBoolean(String key, boolean defaultValue); float getFloat(String key, float defaultValue);  }
@Test public void testGetInt() { assertEquals(55, iniReader.getInt("asdfghjk", 55)); assertEquals(5, iniReader.getInt("intKey", 0)); assertEquals(56, iniReader.getInt("invalidIntKey", 56)); assertEquals(57, iniReader.getInt("anotherInvalidIntKey", 57)); assertEquals(58, iniReader.getInt("blankIntKey", 58)); }