Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.InputStream; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; public class Main { public static <T> T reload(InputStream is, Class<?>... clazz) throws JAXBException { //Create JAXB Context JAXBContext jc = JAXBContext.newInstance(clazz); Unmarshaller um = jc.createUnmarshaller(); return (T) um.unmarshal(is); } }