java - JAXB static marshalling vs JAXBContext createMarshaller() -


i wasted lot of time on following code snippet, finding out , put jaxb.index , how create jaxbcontext

jaxbcontext jc = jaxbcontext.newinstance(new class[]{gena.class, genb.class, ...});  // or jaxbcontext jc = jaxbcontext.newinstance( "my.package.jaxb" ); marshaller m = jc.createmarshaller();  outputstream os = new fileoutputstream( "file.xml" ); m.marshal( object, os ); 

but there static method jaxb.marshal(object, "c:\\path\\file.xml"); making easy 1 expect.

i read creating jaxbcontext resource intense. why should 1 use first method @ all? disadvantages of static method?

a jaxbcontext represents processed metadata converting objects to/from xml. since thread safe can create once , reuse it. performance improvement on using static method.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -