[英]The device is not connected exception
I try to open a large number of files but after 5000 files or so I get 我尝试打开大量文件,但是在5000个文件之后,我得到了
Exception in thread "Main" java.io.IOException: The device is not connected
Is this the expected behavior? 这是预期的行为吗? Is there a way around it?
有办法解决吗? I want to leave my code as straightforward as possible.
我想让我的代码尽可能简单。
What exactly are you trying to achieve? 您到底想达到什么目的?
An open file has some cost in resources, so that opening another file fails when many files are already open is expected behavior. 打开的文件会占用一些资源,因此,当许多文件已经打开时,打开另一个文件将失败,这是预期的行为。 At least it is expecte by myself.
至少我自己期望。
see for example this: http://www.msfn.org/board/lofiversion/index.php/t101414.html 参见以下示例: http : //www.msfn.org/board/lofiversion/index.php/t101414.html
It should not be a problem opening thousands of files if you remember to close() your files when you are done using them? 如果您记得使用完文件后要关闭()文件,打开数千个文件应该不是问题吗?
If not, you force the operating system to maintain state for your open files, which usually is a limited resource. 如果不是,则强制操作系统维护打开文件的状态,这通常是有限的资源。
If you really need lots of simultaneous open files, the solution depends on the circumstances. 如果确实需要大量同时打开的文件,则解决方案取决于具体情况。 What is it you need to do?
您需要做什么? Please show code.
请显示代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.