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());
}
转换成流了,
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());
}
转换成流了,
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货