The size() method of ByteArrayOutputStream class in Java is used to obtain the current size of the buffer. This buffer is accumulated inside the ByteArrayOutputStream. This method returns the size of the current buffer as an integer type.
public int size()
Parameters: This method does not accept any parameter.
Return value: This method returns the size of the current buffer as an integer.
Exceptions: This method does not throw any exception.
Below programs illustrate size() method in ByteArrayOutputStream class in IO package:
G 1 GE 2 GEE 3 GEEK 4 GEEKS 5
G 1 GE 2 GEE 3 GEEK 4 GEEKS 5 GEEKSF 6 GEEKSFO 7 GEEKSFOR 8 GEEKSFORG 9 GEEKSFORGE 10 GEEKSFORGEE 11 GEEKSFORGEEK 12 GEEKSFORGEEKS 13
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.