Created
November 5, 2012 14:58
-
-
Save ageldama/4017588 to your computer and use it in GitHub Desktop.
예외가 있을때와 없을때.
This file contains hidden or 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
| /* 예외를 사용하지 않을때. */ | |
| File file = openFile(); | |
| if (file == null) { | |
| return null; | |
| } | |
| String contents = file.readAll(); | |
| return contents; | |
| /* 예외를 사용할때. */ | |
| File file = null; | |
| try { | |
| file = openFile(); | |
| return file.readAll(); | |
| } finally { | |
| if (file != null) closeFile(file); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment