Java tutorial
//package com.java2s; import java.io.InputStream; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; public class Main { public static Object loadInstance(InputStream inputStream, Class instanceClass) throws JAXBException { Unmarshaller unmarshaller = JAXBContext.newInstance(instanceClass).createUnmarshaller(); Object object = unmarshaller.unmarshal(inputStream); return object; } }