flush(): This method is available in the java.io.CharArrayWriter class of Java.
Syntax:
void java.io.CharArrayWriter.flush()
This method flushes the stream.
Parameters: NA
Returns: NA
Exceptions: NA
Approach
Java
import java.io.CharArrayWriter;import java.io.IOException;public class CharArrayWriterflush {public static void main(String[] args) throws IOException {CharArrayWriter charArrayWriter = new CharArrayWriter();char cbuf[] = { 'a', 'b', 'c', 'd' };charArrayWriter.write(cbuf);charArrayWriter.flush();System.out.println(charArrayWriter.toString());charArrayWriter.close();}}
Output:
abcd
No comments:
Post a Comment