Java examples for JSON:JSON Creation
Writing a JSON Object to File
import java.io.FileWriter; import javax.json.Json; import javax.json.JsonObject; public class Main { public static void main(String[] args) { JsonObject jsonObject = null; try (javax.json.JsonWriter jsonWriter = Json.createWriter(new FileWriter( "Book.json"))) { jsonWriter.writeObject(jsonObject); } catch (Exception ex) { System.out.println(ex); } } }