gpt4 book ai didi

java - Java 流中的flush() 的用途是什么?

转载 作者:行者123 更新时间:2023-12-01 22:58:44 34 4
gpt4 key购买 nike

在Java中,flush()方法用于流中。但我不明白使用这种方法的目的是什么?

fin.flush();

告诉我一些建议。

最佳答案

来自docs flush 方法的:

Flushes the output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.

缓冲主要是为了提高I/O性能。更多关于这方面的内容可以阅读这篇文章:Tuning Java I/O Performance .

关于java - Java 流中的flush() 的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58429013/

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