Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.opendoorgames.test;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.files.FileHandle;
- import com.badlogic.gdx.utils.Json;
- public class JsonFile {
- static Json json = new Json();
- static String external = "Saved Games/Collab-0/";
- String folder;
- FileHandle dir;
- FileHandle file;
- public JsonFile(String folder, String filename) {
- dir = Gdx.files.external(external + folder);
- if (!dir.exists())
- dir.mkdirs();
- file = dir.child(filename);
- }
- public <T> T read(Class<T> object) {
- return json.fromJson(object, file);
- }
- public <T> void write(T object) {
- json.toJson(object, file);
- }
- }
Add Comment
Please, Sign In to add comment