FileConfiguration extends MemoryConfiguration { public void save(File file) throws IOException { Validate.notNull(file, "File cannot be null"); Files.createParentDirs(file); String data = saveToString(); Writer writer = new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8); try { writer.write(data); } finally { writer.close(); } } 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 testSave_File() throws Exception { FileConfiguration config = getConfig(); File file = testFolder.newFile("test.config"); for (Map.Entry<String, Object> entry : getTestValues().entrySet()) { config.set(entry.getKey(), entry.getValue()); } config.save(file); assertTrue(file.isFile()); }
@Test public void testSave_String() throws Exception { FileConfiguration config = getConfig(); File file = testFolder.newFile("test.config"); for (Map.Entry<String, Object> entry : getTestValues().entrySet()) { config.set(entry.getKey(), entry.getValue()); } config.save(file.getAbsolutePath()); assertTrue(file.isFile()); }