Here you can find the source of unmarshal(Class
public static <T> T unmarshal(Class<T> clazz, String xmlInClassPath)
//package com.java2s; //License from project: Open Source License import com.google.common.io.Closeables; import com.google.common.io.Resources; import javax.xml.bind.JAXBContext; import java.io.*; import java.net.URL; public class Main { public static <T> T unmarshal(Class<T> clazz, String xmlInClassPath) { Reader reader = null;// www . j a va 2s . c o m try { URL xmlUrl = Resources.getResource(xmlInClassPath); reader = new InputStreamReader(xmlUrl.openStream(), "UTF-8"); JAXBContext context = JAXBContext.newInstance(clazz); return (T) context.createUnmarshaller().unmarshal(reader); } catch (Exception e) { throw new RuntimeException("Failed to unmarshal object for class:" + clazz + " xml:" + xmlInClassPath, e); } finally { Closeables.closeQuietly(reader); } } }