Commit 115862fe authored by 王炜's avatar 王炜

调整产品excel导入并保存文件可能出现流未正常关闭,内存泄露问题

parent 641c6a94
...@@ -147,10 +147,11 @@ public class ImportExcel extends AbstractEntry { ...@@ -147,10 +147,11 @@ public class ImportExcel extends AbstractEntry {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
FileOutputStream fout = new FileOutputStream(savePath); FileOutputStream fout = new FileOutputStream(savePath);
try {
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
int len = 0; int len = 0;
int size = 0; int size = 0;
while((len = in.read(buffer)) > 0 ){ while ((len = in.read(buffer)) > 0) {
fout.write(buffer, 0, len); fout.write(buffer, 0, len);
size += len; size += len;
} }
...@@ -185,6 +186,14 @@ public class ImportExcel extends AbstractEntry { ...@@ -185,6 +186,14 @@ public class ImportExcel extends AbstractEntry {
cstm.setLong(4, Long.valueOf(user_id));// user_id cstm.setLong(4, Long.valueOf(user_id));// user_id
cstm.execute(); cstm.execute();
cstm.close(); cstm.close();
}finally{
if(fout!=null){
fout.close();
}
if(in!=null){
in.close();
}
}
} }
......
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