Posted By

hoplite on 07/18/17


Tagged

file JAXB


Versions (?)

JAXB FileCreating


 / Published in: Java
 

Write Object XXX with accordingly Annotations to File answer_XXX in according Schema to the Object.

  1. public void marshallXXX( )
  2. {
  3. try
  4. {
  5. /* init jaxb marshaler */
  6. JAXBContext jaxbContext = JAXBContext.newInstance( XXXClass.class );
  7. Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
  8.  
  9. /* set this flag to true to format the output */
  10. jaxbMarshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, true );
  11.  
  12. /* marshaling of java objects in xml (output to file and standard output) */
  13. jaxbMarshaller.marshal( xxx, new File( "answer_XXX.xml" ) );
  14.  
  15.  
  16. }
  17. catch( JAXBException e )
  18. {
  19. e.printStackTrace();
  20. }
  21.  
  22. }

Report this snippet  

You need to login to post a comment.