Commit 706274bd authored by hongguangwu's avatar hongguangwu

1.7.21-优化临时文件

parent 7bd483fd
...@@ -55,10 +55,10 @@ public class ExcelToImage { ...@@ -55,10 +55,10 @@ public class ExcelToImage {
String projectRoot = System.getProperty(CommonConstants.USER_DIR); String projectRoot = System.getProperty(CommonConstants.USER_DIR);
File tempFile = null; File tempFile = null;
File compressedTempFile = null; File compressedTempFile = null;
try {
//加载Excel工作表 //加载Excel工作表
Workbook wb = new Workbook(); Workbook wb = new Workbook();
try {
wb.loadFromHtml(inputStream); wb.loadFromHtml(inputStream);
//获取工作表 //获取工作表
Worksheet sheet = wb.getWorksheets().get(0); Worksheet sheet = wb.getWorksheets().get(0);
...@@ -89,6 +89,9 @@ public class ExcelToImage { ...@@ -89,6 +89,9 @@ public class ExcelToImage {
e.printStackTrace(); e.printStackTrace();
return R.failed(CommonConstants.RESULT_DATA_FAIL+toImagConvertError+e.getMessage()); return R.failed(CommonConstants.RESULT_DATA_FAIL+toImagConvertError+e.getMessage());
} finally { } finally {
if (wb != null) {
wb.dispose(); // 重要:释放资源并删除临时文件
}
if (tempFile != null && tempFile.exists()){ if (tempFile != null && tempFile.exists()){
tempFile.delete(); tempFile.delete();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment