关闭套接字会关闭流吗? [英] Does closing the socket close the stream?
问题描述
-
我正在使用旧版Java应用程序,在许多文件中,使用了套接字和流,其中套接字正在关闭,而流没有关闭,因此在关闭套接字之前必须关闭所有流.因为我收到打开文件太多错误",是因为未关闭流而导致此错误.....
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:
关闭此套接字也会关闭套接字的
InputStream
和OutputStream
.
所以一般来说,关闭套接字应该足以关闭它创建的两个流.
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屋!