The close() method oStringWriter Class in Java is used to close the writer. Closing a writer deallocates any value in it or any resources associated with it. The StringWriter instance once closed won’t work. Also a StringWriter instance once closed cannot be closed again.
public void close()
Parameters: This method does not accepts any parameter.
Return Value: This method does not returns any value. It just closes the Stream.
Below programs illustrates the working of close() method:
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.