Using Gson to load a JSON file from disk.

suggest change

This will load a JSON file from disk and convert it to the given type.

public static <T> T getFile(String fileName, Class<T> type) throws FileNotFoundException {
    Gson gson = new GsonBuilder()
            .create();
    FileReader json = new FileReader(fileName);
    return gson.fromJson(json, type);
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents