Gson throws MalformedJsonException, and other Exceptions
I tried to save data to json string in a txt file using Gson and then restore it using Gson either. Things go well if I do it in eclipse. But when packaged to jar, Gson throws Exceptions. Here is the code for saving the file. String gsonStr = gson.toJson(masterShips); // masterShips is ArrayList<Ship> BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter("D:\\master_ship.txt")); writer.write(gsonStr); } catch (IOException e) { System.err.println(e); } finally { if (writer != null) { try { writer.close(); } catch (IOException e) { System.err.println(e); } } } Then I rea
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.