IniReader { public float getFloat(String key, float defaultValue) { Optional<String> stringOptional = Optional.ofNullable(values.get(key)); try { return stringOptional.map(Float::parseFloat).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 testGetFloat() { assertTrue(Float.compare(iniReader.getFloat("asdfghjk", 7.8f), 7.8f) == 0); assertTrue(Float.compare(iniReader.getFloat("floatKey", 7.8f), 6f) == 0); assertTrue(Float.compare(iniReader.getFloat("anotherFloatKey", 7.8f), 7.3f) == 0); assertTrue(Float.compare(iniReader.getFloat("invalidFloatKey", 7.8f), 7.8f) == 0); assertTrue(Float.compare(iniReader.getFloat("anotherInvalidFloatKey", 7.8f), 7.8f) == 0); }