简体   繁体   English

Java的BufferedReader.readLine()是否将整个文件放在内存中?

[英]Does Java's BufferedReader.readLine() put the whole file in memory?

Does it? 可以? Or maybe only separate strings are put on each readline() and maximal space of memory taken is volume for the longest string? 或者也许只有单独的字符串放在每个readline()上,并且最大的内存空间是最长字符串的音量?

Does it? 可以?

No. 没有。

Or maybe only separate strings are put on each readline() 或者也许每个readline上只放置单独的字符串()

No. 没有。

and maximal space of memory taken is volume for the longest string? 并且最大的内存空间是最长字符串的音量?

No. 没有。

It's a buffered reader. 这是一个缓冲的读者。 That means it has a buffer. 这意味着它有一个缓冲区。 It fills the buffer, to the extent of available data and its own limit, which is or was 4096 characters. 它填充缓冲区,达到可用数据的范围和自己的限制,即4096个字符。 It scans the buffer for a line terminator; 它扫描缓冲区以寻找行终止符; returns the data before it as the next line; 将数据作为下一行返回; and deletes it from the buffer. 并从缓冲区中删除它。 When the buffer is empty it fills it again. 当缓冲区为空时,它会再次填充它。

What the caller does with each readLine() result is up to the caller. 调用者对每个readLine()结果的作用取决于调用者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM