private InputStream input;
private InputStreamReader inputReader;
private BufferedReader reader;
try {
input = new InputStream();
inputStreamReader = new InputStreamReader(inputStream);
reader = new BufferedReader(inputStreamReader);
// do I/O operations
} catch (IOException e) {
Log.d("IOException", "The Data Could Not Be Read =/");
} finally {
try {
reader.close(); // now will this, by default, close all other streams? OR
/*
* input.close(); inputStream.close(); //is this necessary, along with
* reader.close();
*/
} catch (IOException ex) {
ex.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
我今天遇到了这个问题,并且不确定它们是否会被关闭,因为它已被包裹,或者是否仍需要独立关闭所有流.