Here you can find the source of read(Class
public static <T> T read(Class<T> cl, 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 { public static <T> T read(Class<T> cl, InputStream is) throws JAXBException { JAXBContext context = JAXBContext.newInstance(cl); Unmarshaller unmarshaller = context.createUnmarshaller(); T o = cl.cast(unmarshaller.unmarshal(is)); return o; }//from w w w . j a v a 2 s .c o m }