POI 导入导出时异常[java.io.IOException: Broken pipe]

使用用POI导出文件时抛出异常java.io.IOException: Broken pipejava

ERROR:  'java.io.IOException: Broken pipe' org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Fail to save: an error occurs while saving the package : The part /docProps/core.xml fail to be saved in the stream with marshaller org.apache.poi.openxml4j.opc.internal.marshallers.ZipPackagePropertiesMarshaller@783e76d

缘由:输入流,输出流在使用以后(输入流用于构造函数,输出流用于写入数据),再使用一样的流作以前的事会报错(再使用输入流报错流为空,再使用输出流报错为 org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException: Fail to save: an error occurs while saving the package : The part /docProps/app.xml failed to be saved in the stream with marshaller org.apache.poi.openxml4j.opc.internal.marshallers.DefaultMarshaller@4bbfb90a)。因此对于同一个引用的流,在使用以后还想要继续使用的话,必须从新新建一个流对象apache

 

记得使用只用及时关闭 流。为了不在特殊状况下致使流关闭失败,应该吧关闭流的操做放在finally代码块中app

}finally { inputStream.close(); ouputStream.close(); workbook.close(); }
相关文章
相关标签/搜索