Java tutorial
//package com.java2s; import java.io.File; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; public class Main { public final static Object load(Class clazz, String name) { try { File file = new File(name); JAXBContext jaxbContext = JAXBContext.newInstance(clazz); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); return jaxbUnmarshaller.unmarshal(file); } catch (JAXBException e) { e.printStackTrace(); return null; } } }