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();
}
}
मैं आज इस प्रश्न में आया, और मुझे यकीन नहीं है कि वे बंद हो जाएंगे, क्योंकि यह लपेटा गया है, या यदि सभी स्ट्रीम स्वतंत्र रूप से बंद करना आवश्यक है।क्या मुझे जावा के माध्यम से बफर में लपेटा गया है, तो क्या मुझे सभी धाराएं बंद करने की ज़रूरत है?
यह करीब सभी संबंधित है धाराओं का उपयोग कर सकते है ... लेकिन यह wouldn ' अन्य लोगों को चोट पहुंचाने में चोट नहीं – 3kings
@ 3kings - ठीक है, मैं तर्क दूंगा कि अनावश्यक कोड चोट पहुंचाता है। केवल इसके लिए प्रत्येक पाठक/स्ट्रीम पर अतिरिक्त कॉल जोड़ने के बजाय 'बंद()' के अनुबंध पर भरोसा करना बेहतर है। –