Here you can find the source of loadXml(File file, Class
public static <T> T loadXml(File file, Class<T> requireType) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.InputStream; import javax.xml.bind.JAXBContext; import javax.xml.bind.Unmarshaller; public class Main { public static <T> T loadXml(File file, Class<T> requireType) throws Exception { JAXBContext context = JAXBContext.newInstance(requireType); Unmarshaller um = context.createUnmarshaller(); return (T) um.unmarshal(file); }/*from ww w . ja v a 2 s . c o m*/ public static <T> T loadXml(InputStream stream, Class<T> requireType) throws Exception { JAXBContext context = JAXBContext.newInstance(requireType); Unmarshaller um = context.createUnmarshaller(); return (T) um.unmarshal(stream); } }