Use Apache poi download excel spreadsheet accidental causes of failure

Description Event:
the process of service operation, excel download occasionally not available, view production logs, given the information found as follows:
2019-11-18 14: 33 is: 20,268 ERROR [stderr] (Task-61 is default) java.lang.RuntimeException: java.io.IOException: No File or Directory SUCH
2019-11-18 14: 33 is: 20,269 ERROR [stderr] (Task-61 is default) AT org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet (SXSSFWorkbook.java: 640)
2019-11-18 14: 33 is: 20,269 ERROR [stderr] (Task-61 is default) AT org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet (SXSSFWorkbook.java:657)

Cause final positioning is: poi resulting in the temporary directory folder poifiles be periodically cleaned out as garbage.
Temporary Solution: In tmp directory manually create this folder.
Final Solution: Modify the code:

File temp = new File(System.getProperty("java.io.tmpdir"),"poifiles");
if(!temp.exists()){
	temp.mkdir();
}
Published 15 original articles · won praise 0 · Views 308

Guess you like

Origin blog.csdn.net/sinat_15051577/article/details/103388309