我需要合并两个ByteArrayOutputStream并传递给xdo api TemplateHelper.processTemplate以生成报告
下面的代码用于在两个ByteArrayOutputStreams中获取xml输出-
ByteArrayOutputStream hdrclob = new ByteArrayOutputStream (1024);
hdrclob = (ByteArrayOutputStream)this.getDataTemplateXML(transaction,"ASO",
"ASOPD",parameters1,null);
ByteArrayOutputStream conclob = new ByteArrayOutputStream (1024);
ContractTermsXMLGenerator.writeXML(PrintQuote,(OutputStream) conclob, true,
documentType, new Number(params[8]), new Number("0"));现在将hdrclob / conclob分别传递给xdo api,然后可以在单独的报告上看到各自的xml输出,如下所示-
TemplateHelper.processTemplate(((OADBTransactionImpl)transaction).getAppsContext(),
"ASO", "SampleRTF", language, country,
new ByteArrayInputStream(hdrclob.toByteArray()),
TemplateHelper.OUTPUT_TYPE_PDF, new Properties(), pdf); 或
TemplateHelper.processTemplate(((OADBTransactionImpl)transaction).getAppsContext(),
"ASO", "SampleRTF", language, country,
new ByteArrayInputStream(conclob.toByteArray()),
TemplateHelper.OUTPUT_TYPE_PDF, new Properties(), pdf); ,但需要合并hdrclob和conclob以生成单个ByteArrayOutputStream,并传递给xdo api以获得包含两个xml输出的单个报告。
请告诉我如何合并两个ByteArrayOutputStreams
感谢您对此的回复
发布于 2013-07-10 14:50:25
假设这是Java,只需将一个流写入另一个流的末尾。
hdrclob.write(conclob.toByteArray());
// hdrclob.toByteArray() now returns the concatenation of the two streams如果您只想将它们作为单个InputStream顺序读取,则可以构造一个将任意两个输入流连接在一起的SequenceInputStream。
InputStream everything = new SequenceInputStream(
new ByteArrayInputStream(hdrclob.toByteArray()),
new ByteArrayInputStream(conclob.toByteArray()));
// now read everythinghttps://stackoverflow.com/questions/17564021
复制相似问题