Here you can find the source of load(InputStream input, Class
public static <T extends Object> T load(InputStream input, Class<T> type) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; 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 extends Object> T load(InputStream input, Class<T> type) throws IOException { try {//from ww w .ja va 2s. c o m JAXBContext context = JAXBContext.newInstance(type); Unmarshaller um = context.createUnmarshaller(); return (T) um.unmarshal(input); } catch (JAXBException ex) { throw new IOException("Exception thrown while deserializing stream", ex); } } }