Here you can find the source of load(final String xml, final Class
public static <T> T load(final String xml, final Class<T> clazz) throws JAXBException
//package com.java2s; //License from project: Open Source License import java.io.StringReader; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; public class Main { public static <T> T load(final String xml, final Class<T> clazz) throws JAXBException { StringReader reader = new StringReader(xml); try {/*from w w w . ja va 2 s . c om*/ final JAXBContext context = JAXBContext.newInstance(clazz); final Unmarshaller um = context.createUnmarshaller(); @SuppressWarnings("unchecked") final T resource = (T) um.unmarshal(reader); return resource; } // try finally { reader.close(); } // finally } }