关闭套接字会关闭流吗? [英] Does closing the socket close the stream?

查看:220
本文介绍了关闭套接字会关闭流吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我正在使用旧版Java应用程序,在许多文件中,使用了套接字和流,其中套接字正在关闭,而流没有关闭,因此在关闭套接字之前必须关闭所有流.因为我收到打开文件太多错误",是因为未关闭流而导致此错误.....

  1. I am working in a legacy java application, In many files, socket and streams are used, where sockets are getting closed but not the streams, is this necessary to close all the streams before closing the socket. because I am getting "too many open files error", is this error because of not closing the streams.....

关闭套接字还会自动关闭流吗?

closing the socket will automatically close the streams also?

推荐答案

来自

From the Socket Javadoc:

关闭此套接字也会关闭套接字的InputStreamOutputStream.

所以一般来说,关闭套接字应该足以关闭它创建的两个流.

So generally speaking, closing the socket should be enough to close both streams it created.

您的打开文件过多错误"很可能是由其他原因引起的.

Your "too many open files error" is most likely caused by something else.

这篇关于关闭套接字会关闭流吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆