I have a JAXB generated object in memory, and I want to mashal it to XML. But I want it directly as a
String, not written out to a file. How do I do this? Right now, I am using a temperary file, like this...
JAXBContext jc = JAXBContext.newInstance(JAXB_PACKAGE);
Marshaller m = jc.createMarshaller();
OutputStream os = new FileOutputStream("temp.xml");
m.marshal(jaxbObj, os);
os.close();
byte[] bXml = ioMgr.loadFileAsBuffer("temp.xml");
if(bXml != null){
xml = new String(bXml);
}
ioMgr.removeFile("temp.xml");