// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;


public class SaveJAXB {
    public static void main(String[] args) {
        try {
            Data o = new Data(123, 123.456, "ABC");
            JAXBContext jxbctx = JAXBContext.newInstance(Data.class);
            OutputStream os = new FileOutputStream("C:\\jaxb.xml");
            Marshaller m = jxbctx.createMarshaller();
            m.marshal(o, os);
            os.close();
        } catch (JAXBException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
