Here you can find the source of save(File file, T obj, Class>... clazz)
public static <T> void save(File file, T obj, Class<?>... clazz) throws JAXBException
//package com.java2s; //License from project: Open Source License import java.io.File; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; public class Main { public static <T> void save(File file, T obj, Class<?>... clazz) throws JAXBException { //Create JAXB Context JAXBContext jc = JAXBContext.newInstance(clazz); //Create marshaller Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(obj, file);// w ww . j a va2 s .c o m } }