¿¹Á¦
public class
ClassA {
public void
makeStream (File file) {
try
{
FileInputStream stream =
new
FileInputStream(file);
stream.read();
//do something...
stream.close();
}
catch
(IOException e) {
//stream leaked...
}
}
}
¼Ö·ç¼Ç
ÀÚ¿ø ´©¼ö¸¦ ÇÇÇÏ·Á¸é ¸ðµç java.io.FileInputStream¿¡¼ close()°¡ È£ÃâµÇ´ÂÁö È®ÀÎÇϽʽÿÀ.
Âü°í: ÀÌ ±ÔÄ¢Àº ¸ðµç FileInputStream »ý¼ºÀÚ Çü½Ä¿¡ Àû¿ëµË´Ï´Ù.
public class
ClassA {
public void
makeStream (File file) {
FileInputStream stream =
null
;
try
{
stream =
new
FileInputStream(file);
stream.read();
//do something...
}
catch
(IOException e) {
//do something...
}
finally
{
if
(stream !=
null
) {
try
{
stream.close();
}
catch
(IOException e) {
//do something...
}
}
}
}
}