public < TYPE > void write ( @ NotNull final TYPE obj , @ NotNull final File file , @ NotNull final JAXBContext jaxbContext ) throws MarshalObjectException { Contract . requireArgNotNull ( "obj" , obj ) ; Contract . requireArgNotNull ( "file" , file ) ; Contract . requireArgNotNull ( "jaxbContext" , jaxbContext ) ; try { final FileWriter fw = new FileWriter ( file ) ; try { write ( obj , fw , jaxbContext ) ; } finally { fw . close ( ) ; } } catch ( final IOException ex ) { throw new MarshalObjectException ( "Unable to write XML to file: " + file , ex ) ; } }
Marshals the object as XML to a file .