我有一个zip文件的输入流,zip文件有1个XLSX文件,其他是拉链文件,我通过输入流读取XLSX文件,过程完成没有任何问题,但我想使用输入流再次阅读包含在根zip中的photos.zip,这里它触发了一个流关闭异常。这是我的代码。
for (FileItem item : multiparts) {
ZipInputStream zipStream = new ZipInputStream(new ByteArrayInputStream(item.get()));
ZipEntry entry = null;
while ((entry = zipStream.getNextEntry()) != null) {
if (entry.getName().contains(excel)) {
readExcelContent = new ReadExcelContent();
readExcelContent.read(zipStream);
} else if (entry.getName().contains(photoZip)) {
fillContentImage = new FillContentImage();
fillContentImage.read(zipStream, contextPath);
} else if ((entry.getName().contains(videoZip))) {
fillContentVideo = new FillContentVideo();
fillContentVideo.read(zipStream, contextPath);
}
}
}
这是ReadExcel类
public ArrayList<FillContent> read(InputStream stream) {
XSSFWorkbook wb;
try {
wb = new XSSFWorkbook(stream);
XSSFSheet ws = wb.getSheetAt(0);
int rowNum = ws.getLastRowNum() + 1;
for (int i = 0; i < rowNum; i++) {
FillContent objFillContent = new FillContent();
XSSFRow row = ws.getRow(i);
XSSFCell cell = row.getCell(0);
objFillContent.setOrder(i + 1);
objFillContent.setContentName(cell.toString());
cell = row.getCell(1);
objFillContent.setServiceid((int) (Double.parseDouble(cell
.toString())));
cell = row.getCell(2);
objFillContent.setContentDiscreption(cell.toString());
cell = row.getCell(3);
objFillContent.setVideoType(cell.toString());
fillContentExcel.add(objFillContent);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return fillContentExcel;
}