Here you can find the source of save(String fileName, Object o)
public static void save(String fileName, Object o) throws IOException
//package com.java2s; import java.io.FileWriter; import java.io.IOException; import com.google.gson.Gson; import com.google.gson.GsonBuilder; public class Main { public static void save(String fileName, Object o) throws IOException { Gson gson = new GsonBuilder().setPrettyPrinting().create(); try (FileWriter out = new FileWriter(fileName);) { out.write(gson.toJson(o));/*w ww .j av a 2 s. com*/ } } }