miracle just wanna be better

socket流关闭问题

2010-01-01
miracle

下面是常见的关闭网络输出流的写法,但dos.close()的方式会将socket一起关闭掉,所以我们用第二种方法socket.shutdownOutput()的方法.

 DataOutputStream dos1 = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
 dos1.close();
 socket.shutdownOutput();

上一篇 Java常见错误

Comments

Content