StringWriter has a flush function. What does it mean to flush a string buffer?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It must have an implementation of
flush()because in its superclassWriterthat’s an abstract method, andStringWriteris not an abstract class. However, if you look at the source code ofStringWriter.flush(), which you can find in the filesrc.zipin your JDK installation directory, you’ll see:In other words, it does nothing. (There are ofcourse other subclasses of
Writerwhereflush()does do something useful).The person who implemented this method could have documented that it doesn’t do anything, but they didn’t.