Created
June 3, 2014 22:15
-
-
Save james-prickett/01aea289fd5c7c927f33 to your computer and use it in GitHub Desktop.
JAXB Example
This file contains hidden or 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 void main(String[] args) { | |
| try { | |
| JAXBContext jaxbContext = JAXBContext.newInstance("com.prickettfamily.java.jaxb"); | |
| Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); | |
| Person person = (Person)unmarshaller.unmarshal(new File("/home/james/person.xml")); | |
| assert person.getName().equals("John Doe"); | |
| assert person.getPhone().equals("555-5555"); | |
| assert person.getAddress().getStreet().equals("5 Somewhere Lane"); | |
| } catch (JAXBException e) { | |
| e.printStackTrace(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment