The close() method of ByteArrayOutputStream class in Java has no effect if other methods of this class are called after closing the ByteArrayOutputStream. This method does not throw exception if even after closing the ByteArrayOutputStream, the other method is called.
public void close()
Specified By: This method is specified by close() method of AutoCloseable interface and close() method of Closeable interface.
Overrides:This method overrides close() method of OutputStream class.
Parameters: This method does not accept any parameter.
Return value: This method does not return any value.
Exceptions: This method does not throw any exception.
Below programs illustrate close() method in ByteArrayOutputStream class in IO package:
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.