猿问

Java中流的关闭

1.response.getWriter().print("");
2.PrintWriterout=response.getWriter();
out.print("");
out.close();
第一种方式可以吗?流会自动关闭吗?
慕姐8265434
浏览 362回答 2
2回答

慕森卡

response.getWriter().print("");不会自动关闭response.getWriter源码publicPrintWritergetWriter()/**/throwsIOException/**/{/*213*/PrintWriterwriter=this.response.getWriter();/*214*/if(isFinished()){/*215*/this.response.setSuspended(true);/**/}/*217*/returnwriter;/**/}print方法源码publicvoidprint(Strings){if(s==null){s="null";}write(s);}
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答