// Write JSON string to a file try (FileWriter file = new FileWriter("fileName.json")) { file.write(data); // data is a JSON string here file.flush(); } catch (IOException e) { e.printStackTrace(); }