Here you can find the source of serializeToXmlFile(T object, String fileName)
public static <T> void serializeToXmlFile(T object, String fileName)
//package com.java2s; //License from project: Open Source License import java.io.FileOutputStream; import java.io.IOException; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; public class Main { public static <T> void serializeToXmlFile(T object, String fileName) { try {//from w w w. ja v a2 s.co m JAXBContext context = JAXBContext.newInstance(object.getClass()); try (FileOutputStream outStream = new FileOutputStream(fileName)) { context.createMarshaller().marshal(object, outStream); } } catch (JAXBException | IOException e) { } } }