¿¹Á¦

public class ClassA {

public void makeStream (InputStream iStream) {

try {
DataInputStream stream = new DataInputStream(iStream);
stream.read();
//do something...

stream.close();

}
catch (IOException e) {
//stream leaked...
}
}
}



¼Ö·ç¼Ç
ÀÚ¿ø ´©¼ö¸¦ ÇÇÇÏ·Á¸é ¸ðµç java.io.DataInputStream¿¡¼­ close()°¡ È£ÃâµÇ´ÂÁö È®ÀÎÇϽʽÿÀ.
Âü°í: ÀÌ ±ÔÄ¢Àº ¸ðµç DataInputStream »ý¼ºÀÚ Çü½Ä¿¡ Àû¿ëµË´Ï´Ù.


public class ClassA {

public void makeStream (InputStream iStream) {

DataInputStream stream = new DataInputStream(iStream);
try {
stream.read();
//do something...

}
catch (IOException e) {
//do something...

}
finally {
if (stream != null) {
try {
stream.close();

}
catch(IOException e) {
//do something...

}
}
}
}
}