package com.techcavern.wavetact.objects;

import com.google.common.io.Files;
import com.google.gson.Gson;
import com.techcavern.wavetact.utils.Constants;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.Charset;

public class JSONFile {
    private File file;

    public JSONFile(String a) {
        File b = new File(a);
        this.file = b;
    }

    public void write(Object obj, boolean pretty) throws IOException {
        if (!file.exists()) {
            Files.touch(file);
        }
        Gson gson = pretty ? Constants.GSON_PRETTY_PRINT : Constants.GSON;
        Files.write(gson.toJson(obj), file, Charset.forName("UTF-8"));
    }

    public void write(Object obj) throws IOException {
        write(obj, true);
    }

    public boolean exists() {
        return file.exists();
    }

    public <T> T read(Class<T> clazz) throws FileNotFoundException {
        return Constants.GSON.fromJson(Files.newReader(file, Charset.forName("UTF-8")), clazz);
    }
}

@@ -305,16 +305,84 @@
 private 
+final Charset charset = Charset.forName(%22UTF-8%22);%0A    private final 
 File fil
@@ -429,15 +429,13 @@
     
-F
+f
 ile 
-b 
 = ne
@@ -449,31 +449,8 @@
 a);%0A
-        this.file = b;%0A
     
@@ -536,21 +536,16 @@
    if (!
-file.
 exists()
@@ -545,18 +545,16 @@
 xists())
- %7B
 %0A       
@@ -581,18 +581,8 @@
 e);%0A
-        %7D%0A
     
@@ -700,32 +700,15 @@
 le, 
-C
+c
 harset
-.forName(%22UTF-8%22)
 );%0A 
@@ -1002,32 +1002,15 @@
 le, 
-C
+c
 harset
-.forName(%22UTF-8%22)
 ), c

Clean up the JSONFile class