看板 java 關於我們 聯絡資訊
當file丟出exception後file會不會自動執行close()啊? 本來想寫以下的code: RandomAccessFile test = null; try { test = new RandomAccessFile("test.dat", "r"); ... } catch (FileNotFoundException e) { ... } (一堆catch...) finally { test.close(); } 可是compile時compiler說finally裡面的test要放在try裡面, 這樣不就一直try try try try ... 無窮回圈 = = 我是擔心丟出Exception之後file不會自動執行close()才這樣寫的啦, 不然test.close()寫在try最後面就好了, 還是我多慮了~"~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.102.28 ※ 編輯: ericsys3152 來自: 140.116.102.28 (01/07 22:30)