在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 方法的> docs:
From the docs of the flush method:
刷新输出流并强制写出任何缓冲的输出字节。 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性能。有关这方面的更多信息,请参阅以下文章:调整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()的目的是什么?
发布评论