use of com.solinia.solinia.Models.SoliniaAAAbility in project solinia3-core by mixxit.
the class JsonAAAbilityRepository method commit.
@Override
public void commit() {
// TODO Auto-generated method stub
GsonBuilder gsonbuilder = new GsonBuilder();
// gsonbuilder.setPrettyPrinting();
gsonbuilder.registerTypeAdapterFactory(new ISoliniaAARankTypeAdapterFactory(SoliniaAARank.class));
gsonbuilder.registerTypeAdapterFactory(new ISoliniaAAEffectTypeAdapterFactory(SoliniaAAEffect.class));
Gson gson = gsonbuilder.create();
String jsonOutput = gson.toJson(aaabilities.values(), new TypeToken<List<SoliniaAAAbility>>() {
}.getType());
try {
File file = new File(filePath);
if (!file.exists())
file.createNewFile();
FileOutputStream fileOut = new FileOutputStream(file);
OutputStreamWriter outWriter = new OutputStreamWriter(fileOut);
outWriter.append(jsonOutput);
outWriter.close();
fileOut.close();
System.out.println("Commited " + aaabilities.size() + " AA abilities");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations