62,628
社区成员
发帖
与我相关
我的任务
分享
。。。
printout.close();
printout = null;
out.close();
out = null;
input.close();
input = null;
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
try
{
if (null != printout)
{
printout.close();
printout = null;
}
if (null != out)
{
out.close();
out = null;
}
if (null != input)
{
input.close();
input = null;
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
public class DisposeUtil {
public static void safeClose(java.io.Closeable obj){
if(obj == null)
return;
try{
obj.close();
}catch(Throwable e){}
}
}
try{
......
}finally{
DisposeUtil.safeClose(printout);
DisposeUtil.safeClose(out);
DisposeUtil.safeClose(input);
}