-
-
Save poad/5151969 to your computer and use it in GitHub Desktop.
Java6でのリソースと例外処理 ref: http://qiita.com/items/4cb9b0791e2f882cefff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
InputStream in = null; | |
try { | |
in = new FileInputStream("test.txt"); | |
// stream操作 | |
} catch (IOException e) { | |
// error処理 | |
} finally { | |
try { // 必要に応じて | |
if (in != null) { | |
in.close(); | |
} | |
} catch (IOException e) { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
InputStream in = new FileInputStream("test.txt"); | |
try { | |
// stream操作 | |
} finally { | |
try { // 必要に応じて | |
in.close(); | |
} catch (IOException e) { | |
} | |
} | |
} catch (IOException e) { | |
// error処理 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment