Here you can find the source of unmarshaller(Class
public static <T> T unmarshaller(Class<T> entityType, InputStream in) throws JAXBException
//package com.java2s; //License from project: Apache License import java.io.InputStream; import java.io.Reader; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; public class Main { public static <T> T unmarshaller(Class<T> entityType, InputStream in) throws JAXBException { Unmarshaller unmarshaller = createUnmarshaller(entityType); return (T) unmarshaller.unmarshal(in); }//from ww w. ja va 2 s. co m public static <T> T unmarshaller(Class<T> entityType, Reader reader) throws JAXBException { Unmarshaller unmarshaller = createUnmarshaller(entityType); return (T) unmarshaller.unmarshal(reader); } public static Unmarshaller createUnmarshaller(Class<?> clazz) throws JAXBException { JAXBContext jaxbContext = JAXBContext.newInstance(clazz); return jaxbContext.createUnmarshaller(); } }