size(): This method is available in the java.io.CharArrayWriter class of Java.
Syntax:
int java.io.CharArrayWriter.size()
This method returns the current size of the buffer.
Parameters: NA
Returns: an int representing the current size of the buffer.
Exceptions: NA
Approach
Java
import java.io.CharArrayWriter;import java.io.IOException;public class CharArrayWritersize {public static void main(String[] args) throws IOException {CharArrayWriter charArrayWriter = new CharArrayWriter();char cbuf[] = { 'a', 'b', 'c', 'd' };charArrayWriter.write(cbuf);System.out.println(charArrayWriter.size());charArrayWriter.close();}}
Output:
4
No comments:
Post a Comment