Here you can find the source of save(Class confClass, Object confObj, File xmlFile)
public static void save(Class confClass, Object confObj, File xmlFile) throws Exception
//package com.java2s; // Splunk Inc. licenses this file import java.io.File; import java.io.FileWriter; import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; public class Main { public static void save(Class confClass, Object confObj, File xmlFile) throws Exception { JAXBContext context = JAXBContext.newInstance(confClass); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.marshal(confObj, new FileWriter(xmlFile)); }// ww w. ja va 2 s .c o m }