我,如果下面的代碼在關閉的InputStream finally塊正確在finally塊中靜默關閉InputStream而不丟失原始異常的正確方法是什麼?
InputStream is = new FileInputStream("test");
try {
for(;;) {
int b = is.read();
...
}
} finally {
try {
is.close();
} catch(IOException e) {
}
}
如果is.read期間發生異常時想()將它忽略/抑制如果is.close期間發生異常()?
與IOUtils關閉你不能捕獲該異常之前的最後處理呢? – 2013-04-23 08:04:48
在https://code.google.com/p/guava-libraries/wiki/ClosingResourcesExplained和https://code.google.com/p/guava-libraries/issues/detail?id上查看以下兩個鏈接= 1118和 – artfullyContrived 2013-04-23 08:51:03