public InputStream getStreamFromModel(ICommonModel model) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(baos, ENCODING);
Document doc = getModelFeature(model);
try {
OutputFormat format = new OutputFormat(doc, ResourcesPlugin.getEncoding(), true);
XMLSerializer serializer = new XMLSerializer(baos, format);
serializer.serialize(doc);
} catch (IOException e) {
e.printStackTrace();
} finally {
osw.close();
}
return new ByteArrayInputStream(baos.toByteArray());
}
转换成流了,