【发布时间】:2014-11-26 10:07:27
【问题描述】:
我试图将 3 字节数组组合成一个单独的数组来生成报告。
byte[] bArray=null;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream( );
for(int i=0;i<3;i++)
{
//Other stuff
bArray = getTheReportContent(); //The return type of this method is List<byte[]>
outputStream.write(bArray);
}
byte bArrayCombined[] = outputStream.toByteArray( ); //Checked the count. bArrayCombined.length=sum of all the 3 bArray
response.setContentLength((int) bArrayCombined.length);
outStream.write(bArrayCombined, 0, bArrayCombined.length);
outStream.flush();
当我将其写入报告时,内容与预期不符。它仅显示第一个 bArray 内容。我在这里出错的地方。
编辑:
getTheReportContent 执行以下操作:
使用 jasper 导出报告。并返回 byteArrList。
List byteArrList = new ArrayList();
--------
exporterXLS.exportReport();
byteArrList.add(outputStream.toByteArray());
【问题讨论】:
-
getTheReportContent() 实际上做了什么?
-
你确定
getTheReportContent();返回列表吗? -
是的..请查看更新后的问题。
-
检查exportReport/getTheReportContent函数是否第二次和第三次返回null
-
我问你这个问题是因为我看到一个 List
被分配给 byte[] bArray = getTheReportContent();
标签: java bytearray bytearrayoutputstream