在释放多个IO资源时,都会抛出IOException ,于是可能为了省事如此写:
public static void inputToOutput(InputStream is, OutputStream os,
boolean isClose) throws IOException {
BufferedInputStream bis = new BufferedInputStream(is, 1024);
BufferedOutputStream bos = new BufferedOutputStream(os, 1024);
….
if (isClose) {
bos.close();
bis.close();
}
}
假设bos关闭失败,bis还能关闭吗?
|