Here you can find the source of fromXml(Class
public static <T> T fromXml(Class<T> tClass, InputStream inputStream)
//package com.java2s; //License from project: Open Source License import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import java.io.InputStream; public class Main { public static <T> T fromXml(Class<T> tClass, InputStream inputStream) { JAXBContext jaxbContext = null; try {// ww w. j a v a2 s . co m jaxbContext = JAXBContext.newInstance(tClass); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); return (T) jaxbUnmarshaller.unmarshal(inputStream); } catch (JAXBException e) { e.printStackTrace();//TODO:log return null; } } }