Here you can find the source of writeObjectToFile(String filename, T object)
Parameter | Description |
---|---|
file | a parameter |
object | a parameter |
public static <T> void writeObjectToFile(String filename, T object)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; import com.fasterxml.jackson.databind.ObjectMapper; public class Main { /**/* w w w.j av a2s . c om*/ * write the object to a json file * @param file * @param object */ public static <T> void writeObjectToFile(String filename, T object) { ObjectMapper mapper = new ObjectMapper(); File file = new File(filename); try { mapper.writeValue(file, object); } catch (IOException e) { System.err.println("error write object as json file: " + object + " for " + e); } } }