Using Gson to load a JSON file from disk.
suggest changeThis 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);
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents