gpt4 book ai didi

java - Files.readAllLines - 什么构成 "large"文件?

转载 作者:塔克拉玛干 更新时间:2023-11-01 23:04:49 25 4
gpt4 key购买 nike

Files.readAllLines javadoc 指出:

"Note that this method is intended for simple cases where it is convenient to read all lines in a single operation. It is not intended for reading in large files."

在这种情况下什么构成大文件? (我也很好奇为什么不建议大文件使用。是实际的 I/O 问题,还是用于存储读取结果的内存大小?)

最佳答案

问题在于此方法将文本文件的所有 内容读入内存。如果它太大,您只会收到 java.lang.OutOfMemoryError

是的,澄清一下: 是一个相对术语。无法指定其数量,因为它取决于特定机器上的可用内存。

关于java - Files.readAllLines - 什么构成 "large"文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42045787/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com