在 Java 中,flush() 方法用于流中.但是我不明白使用这种方法的所有目的是什么?
In Java, flush() method is used in streams. But I don't understand what are all the purpose of using this method?
fin.flush();告诉我一些建议.
推荐答案来自 flush 方法的rel="noreferrer">文档:
From the docs of the flush method:
刷新输出流并强制写出任何缓冲的输出字节.刷新的一般约定是调用它表明,如果先前写入的任何字节已被输出流的实现缓冲,则应立即将这些字节写入其预期目的地.
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性能.可以从这篇文章中阅读更多相关信息:调整 Java I/O 性能.
The buffering is mainly done to improve the I/O performance. More on this can be read from this article: Tuning Java I/O Performance.
更多推荐
Java流中flush()的目的是什么?
发布评论