/**
* Saves a serializable object to a given file.
*
* @param instance Object to seriaize
* @param file File to save to
* @throws IllegalArgumentException If the instance or file is null
* @throws IOException If the file cannot be written to
* @see #load(File, Class, boolean)
*/
public static void save(ConfigurationSerializable instance, File file) throws IOException
{
Validate.notNull(instance, "instance cannot be null!");
Validate.notNull(file, "file cannot be null!");
file.delete();
file.createNewFile();
YamlConfiguration config = new YamlConfiguration();
for (Entry<String, Object> entry : instance.serialize().entrySet())
{
config.set(entry.getKey(), entry.getValue());
}
config.save(file);
}
FileSerialization.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:SwornAPI
作者:
评论列表
文章目录