Java流中flush()的目的是什么?

编程入门 行业动态 更新时间:2024-10-11 01:12:02
本文介绍了Java流中flush()的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在 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()的目的是什么?

本文发布于:2023-11-25 21:14:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631371.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:目的   Java   flush

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!