String resourceName = "/assets/vmc/BookPages/" + pageID + ".json";
BufferedReader pageScan = new BufferedReader(new InputStreamReader(getClass().getClassLoader ().getResourceAsStream(resourceName), "UTF-8"));
String pageString = "";
while(pageScan.ready()){
pageString += pageScan.readLine();
}
JsonObject pageData = new Gson().fromJson(ResourceManager.getString(pageString), JsonObject.class);
pageName = pageData.get("name").getAsString();
I guess I should explain why I'm doing this.
Before attempting to make this .json file into a string, I was reading a plain text file and reading each line into a variable in an object in an array. The text files obviously started to get really ugly, so I wanted to format it as JSON, which is exactly the format that I was emulating with the arrays. GSON made this mostly easy except that it needs a string for an input. Is there a way I can get this JSON document into a string, or am I missing something that would make this much easier?
The code above causes nullpointerexception crash from the inputStreamReader on the second line, which was previously working fine.