Here you can find the source of saveModel(JAXBElement model, String packageName)
Parameter | Description |
---|---|
model | a parameter |
packageName | a parameter |
public static String saveModel(JAXBElement model, String packageName)
//package com.java2s; import java.io.ByteArrayOutputStream; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.Marshaller; public class Main { /**//from ww w . j av a 2 s .c o m * * @param model * @param packageName * @return */ public static String saveModel(JAXBElement model, String packageName) { JAXBContext jc; try { jc = JAXBContext.newInstance(packageName); Marshaller m = jc.createMarshaller(); ByteArrayOutputStream o = new ByteArrayOutputStream(); m.marshal(model, o); return new String(o.toByteArray()); } catch (Exception e) { e.printStackTrace(); } return ""; } }