Java流的正确关闭方式
时间:2014-07-11 10:09:42
收藏:0
阅读:551
因为流是无论如何一定要关闭的,所以要写在finally里。如下:
BufferedReader reader = null; try { reader = (BufferedReader) getReaderFromFile(file); …… } catch (IOException e) { throw e; } finally { if (reader != null) { try { reader.close(); } catch (IOException e){ throw e; } } }
原文:http://www.cnblogs.com/hamhog/p/3834423.html
评论(0)