Commit db3ad21f by 翁国栋

8小时后台--

关闭流
parent 4e8da25d
...@@ -1707,8 +1707,9 @@ public class InsureContorll { ...@@ -1707,8 +1707,9 @@ public class InsureContorll {
public Result<Object> replaceUserPolicy(@RequestParam("file") MultipartFile file, @RequestParam("policyId") Integer policyId){ public Result<Object> replaceUserPolicy(@RequestParam("file") MultipartFile file, @RequestParam("policyId") Integer policyId){
InsurePolicy insurePolicy = InsurePolicy.builder().id(policyId).build().selectById(); InsurePolicy insurePolicy = InsurePolicy.builder().id(policyId).build().selectById();
ByteArrayOutputStream bos = null; ByteArrayOutputStream bos = null;
XSSFWorkbook xw=null;
try { try {
XSSFWorkbook xw = new XSSFWorkbook(file.getInputStream()); xw = new XSSFWorkbook(file.getInputStream());
XSSFSheet sheetAt = xw.getSheetAt(0); XSSFSheet sheetAt = xw.getSheetAt(0);
//默认第一行为标题行,i = 0 //默认第一行为标题行,i = 0
XSSFRow titleRow = sheetAt.getRow(0); XSSFRow titleRow = sheetAt.getRow(0);
...@@ -1854,6 +1855,11 @@ public class InsureContorll { ...@@ -1854,6 +1855,11 @@ public class InsureContorll {
throw new CustomException("导入异常"); throw new CustomException("导入异常");
}finally { }finally {
try { try {
xw.close();
} catch (IOException e) {
throw new CustomException("XSSFWorkbook流关闭异常");
}
try {
bos.close(); bos.close();
} catch (IOException e) { } catch (IOException e) {
throw new CustomException("ByteArrayOutputStream流关闭异常"); throw new CustomException("ByteArrayOutputStream流关闭异常");
......
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