FileConfiguration extends MemoryConfiguration { public void load(File file) throws FileNotFoundException, IOException, InvalidConfigurationException { Validate.notNull(file, "File cannot be null"); final FileInputStream stream = new FileInputStream(file); load(new InputStreamReader(stream, Charsets.UTF_8)); } FileConfiguration();  FileConfiguration(Configuration defaults); void save(File file); void save(String file); abstract String saveToString(); void load(File file); @Deprecated void load(InputStream stream); void load(Reader reader); void load(String file); abstract void loadFromString(String contents); @Override FileConfigurationOptions options();  }
@Test public void testLoad_File() throws Exception { FileConfiguration config = getConfig(); File file = testFolder.newFile("test.config"); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); String saved = getTestValuesString(); Map<String, Object> values = getTestValues(); try { writer.write(saved); } finally { writer.close(); } config.load(file); for (Map.Entry<String, Object> entry : values.entrySet()) { assertEquals(entry.getValue(), config.get(entry.getKey())); } assertEquals(values.keySet(), config.getKeys(true)); }
@Test public void testLoad_String() throws Exception { FileConfiguration config = getConfig(); File file = testFolder.newFile("test.config"); BufferedWriter writer = new BufferedWriter(new FileWriter(file)); String saved = getTestValuesString(); Map<String, Object> values = getTestValues(); try { writer.write(saved); } finally { writer.close(); } config.load(file.getAbsolutePath()); for (Map.Entry<String, Object> entry : values.entrySet()) { assertEquals(entry.getValue(), config.get(entry.getKey())); } assertEquals(values.keySet(), config.getKeys(true)); }