提交 2f0aa4cc authored 作者: 艾庆国's avatar 艾庆国

代码优化

上级 89441ae6
...@@ -67,9 +67,10 @@ public class NbBankThirdpartyServiceImpl implements NbBankThirdpartyService { ...@@ -67,9 +67,10 @@ public class NbBankThirdpartyServiceImpl implements NbBankThirdpartyService {
*/ */
private static void downloadUsingStream(String urlStr, String file) throws IOException { private static void downloadUsingStream(String urlStr, String file) throws IOException {
URL url = new URL(urlStr); URL url = new URL(urlStr);
BufferedInputStream bis = new BufferedInputStream(url.openStream()); BufferedInputStream bis = null;
FileOutputStream fis = null; FileOutputStream fis = null;
try { try {
bis = new BufferedInputStream(url.openStream());
fis = new FileOutputStream(file); fis = new FileOutputStream(file);
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
int count = 0; int count = 0;
...@@ -78,7 +79,7 @@ public class NbBankThirdpartyServiceImpl implements NbBankThirdpartyService { ...@@ -78,7 +79,7 @@ public class NbBankThirdpartyServiceImpl implements NbBankThirdpartyService {
} }
}finally { }finally {
if (fis != null){fis.close();} if (fis != null){fis.close();}
bis.close(); if (bis != null){bis.close();}
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论