Last active
December 26, 2015 02:59
-
-
Save lanwen/7082123 to your computer and use it in GitHub Desktop.
Way to unmarshall jaxb-objects from xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> T unmarshal(Class<T> clazz, String xml) throws JAXBException { | |
JAXBContext jc = JAXBContext.newInstance(clazz); | |
Unmarshaller u = jc.createUnmarshaller(); | |
JAXBElement<T> root = u.unmarshal(new StreamSource(IOUtils.toInputStream(xml)), clazz); | |
return root.getValue(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment