Java XML JAXB Serialize save(Class confClass, Object confObj, File xmlFile)

Here you can find the source of save(Class confClass, Object confObj, File xmlFile)

Description

save

License

Apache License

Declaration

public static void save(Class confClass, Object confObj, File xmlFile) throws Exception 

Method Source Code


//package com.java2s;
// Splunk Inc. licenses this file

import java.io.File;

import java.io.FileWriter;
import javax.xml.bind.JAXBContext;

import javax.xml.bind.Marshaller;

public class Main {
    public static void save(Class confClass, Object confObj, File xmlFile) throws Exception {
        JAXBContext context = JAXBContext.newInstance(confClass);
        Marshaller m = context.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        m.marshal(confObj, new FileWriter(xmlFile));

    }//  ww  w.  ja  va  2  s .c o m
}

Related

  1. deserialize(Path input, Class clazz)
  2. deserialize(String data, String className)
  3. deserializeFile(String path, Class clazz)
  4. deserializeFromXmlFile(T defaultObject, String fileName)
  5. deserializeXmlToJava(String valueType, Serializable value)
  6. save(File file, T obj, Class... clazz)
  7. saveDataToFile(File file, T data)
  8. saveModel(JAXBElement model, String packageName)
  9. saveObject(Path path, T object)