@SuppressWarnings("unchecked") public static void writeToFile(Writer writer) { for (AchievementIcon ai : iconList) { JSONObject obj = new JSONObject(); obj.put("name", ai.getName()); obj.put("progress", ai.getProgress()); try { writer.write(obj.toString() + "\n"); } catch (IOException e) { e.printStackTrace(); } } }