What is the purpose of flush() in Java streams?
问题 In Java, flush() method is used in streams. But I don\'t understand what are all the purpose of using this method? fin.flush(); tell me some suggestions. 回答1: 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