Created
June 12, 2018 18:40
-
-
Save yccheok/8a8d98007eda1f218564fc21dac446af 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
| /** | |
| * Performs close operation on Closeable stream, without the need of | |
| * writing cumbersome try...catch block. | |
| * | |
| * @param closeable The closeable stream. | |
| */ | |
| public static void close(Closeable closeable) { | |
| // Instead of returning boolean, we will just simply swallow any | |
| // exception silently. This is because this method will usually be | |
| // invoked within finally block. If we are having control statement | |
| // (return, break, continue) within finally block, a lot of surprise may | |
| // happen. | |
| // http://stackoverflow.com/questions/48088/returning-from-a-finally-block-in-java | |
| if (null != closeable) { | |
| try { | |
| closeable.close(); | |
| } catch (IOException ex) { | |
| Log.e(TAG, "", ex); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment