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()
    FileReader json = new FileReader(fileName);
    return gson.fromJson(json, type);

Feedback about page:

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

Table Of Contents