Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import generated.Address;
- import generated.Human;
- import generated.ObjectFactory;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- public class Main {
- public static void main(String[] args) {
- Human h2 = new ObjectFactory().createHuman();
- try {
- javax.xml.bind.JAXBContext jaxbCtx = javax.xml.bind.JAXBContext.newInstance(h2.getClass().getPackage().getName());
- javax.xml.bind.Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
- System.out.println("\n========= Input File =========\n");
- h2 = (Human) unmarshaller.unmarshal(new java.io.File("C://web/me.xml")); //NOI18N
- System.out.println("FirstName : "+h2.getFirstName());
- System.out.println("SurName : "+h2.getSurName());
- System.out.println("Sex : "+h2.getSex());
- System.out.println("Ages : "+h2.getAge());
- Address add2 = h2.getAddress();
- System.out.println("Home number : "+add2.getHomenumber());
- System.out.println("Street :"+add2.getStreet());
- System.out.println("Tumbol : "+add2.getTumbol());
- System.out.println("Amphur : "+add2.getAmphur());
- System.out.println("Province : "+add2.getProvince());
- System.out.println("Postcode : "+add2.getPostcode());
- } catch (javax.xml.bind.JAXBException ex) {
- System.out.println("File not found");
- //java.util.logging.Logger.getLogger("global").log(java.util.logging.Level.SEVERE, null, ex); //NOI18N
- }
- } // end main
- } // end class
Advertisement
Add Comment
Please, Sign In to add comment