首页 > 编程知识 正文

粗糙度及标注方法示例文库,百分位数的计算方法及示例

时间:2023-05-05 02:38:29 阅读:264472 作者:1153

BufferedWriter类flush()方法 (BufferedWriter Class flush() method)

flush() method is available in java.io package.

flush()方法在java.io包中可用。

flush() method is used to flushes the characters from a write buffer to the character or byte stream.

flush()方法用于将字符从写缓冲区刷新到字符或字节流。

flush() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

flush()方法是一种非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

flush() method may throw an exception at the time of flushing the stream.

flush()方法在刷新流时可能会引发异常。

IOException: This exception may throw an exception while performing input/output operation.

IOException :在执行输入/输出操作时,此异常可能会引发异常。

Syntax:

句法:

public Writer flush();

Parameter(s):

参数:

It does not accept any parameter.

它不接受任何参数。

Return value:

返回值:

The return type of the method is Writer, it returns nothing.

该方法的返回类型为Writer ,不返回任何内容。

Example:

例:

// Java program to demonstrate the example // of Writer flush() method of// BufferedWriterimport java.io.*;public class FlushBW { public static void main(String[] args) { String str = "Java Programming"; try { // Instantiates StringWriter StringWriter str_w = new StringWriter(); // Instantiates BufferedWriter BufferedWriter buff_w = new BufferedWriter(str_w); for (char ch: str.toCharArray()) { // To append character by using // append() to the writer buff_w.append(ch); // It flushes the characters // from buff_w to char or byte // stream buff_w.flush(); // Display Buffer from str_w System.out.println("str_w.getBuffer():" + str_w.getBuffer()); } // Close the stream buff_w.close(); } catch (IOException ex) { System.out.println("buff_w: " + ex.getMessage()); } }}

Output

输出量

str_w.getBuffer():Jstr_w.getBuffer():Jastr_w.getBuffer():Javstr_w.getBuffer():Javastr_w.getBuffer():Java str_w.getBuffer():Java Pstr_w.getBuffer():Java Prstr_w.getBuffer():Java Prostr_w.getBuffer():Java Progstr_w.getBuffer():Java Progrstr_w.getBuffer():Java Prograstr_w.getBuffer():Java Programstr_w.getBuffer():Java Programmstr_w.getBuffer():Java Programmistr_w.getBuffer():Java Programminstr_w.getBuffer():Java Programming

翻译自: https://www.includehelp.com/java/bufferedwriter-flush-method-with-example.aspx

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。