flush(): This method is available in the java.io.FilterOutputStream class of Java.
Syntax:
void java.io.FilterOutputStream.flush() throws IOException
This method flushes this output stream and forces any buffered output bytes to be written out to the stream.
The flush method of FilterOutputStreamcalls the flush method of its underlying output stream.
Parameters: NA
Returns: NA
Throws:
IOException - if an I/O error occurs.
Approach
Java
import java.io.File;import java.io.FileOutputStream;import java.io.FilterOutputStream;import java.io.IOException;public class FilterOutputStreamflush {public static void main(String[] args) throws IOException {File data = new File("D:\\hello.txt");FileOutputStream file = new FileOutputStream(data);FilterOutputStream filter = new FilterOutputStream(file);filter.flush();System.out.println("Successfully flush the filter output stream");filter.close();}}
Output:
Successfully flush the filter output stream
Some other methods of FilterOutputStream
close(): This method closes this output stream and releases any system resources associated with the stream.
write(byte[]): This method writes b.length bytes to this output stream.
write(int): This method writes the specified byte to this output stream.
write(byte[], int, int): This method writes len bytes from the specified byte array starting at offset off to this output stream.
No comments:
Post a Comment