Here you can find the source of fromXML(Class
@SuppressWarnings("unchecked") public static <T> T fromXML(Class<T> clazz, InputStream is) throws JAXBException
//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 { @SuppressWarnings("unchecked") public static <T> T fromXML(Class<T> clazz, InputStream is) throws JAXBException { JAXBContext context = JAXBContext.newInstance(clazz); Unmarshaller unmarshaller = context.createUnmarshaller(); return (T) unmarshaller.unmarshal(is); }/*from ww w .j ava 2s . co m*/ }