read and write data with GSON

后端 未结 5 736
予麋鹿
予麋鹿 2021-01-11 21:23

I am struggling to find a good example on how to read and write data in my android app using GSON. Could someone please show me or point me to a good example? I am using thi

5条回答
  •  时光说笑
    2021-01-11 22:07

    Maybe in more recent version, but toJson accepts writer that directly writes to file.

    ex.:

    Vector v = new Vector(10.0f, 20.0f);
    Gson gson = new GsonBuilder().create(); 
    Writer writerJ = new FileWriter("keep.json");
    gson.toJson(v,writerJ);
    

提交回复
热议问题