Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

io - How do you "empty" a StringWriter in Java?

What is the correct way to "empty" a StringWriter in Java so that I can reuse the StringWriter without having to create a new one? Neither StringWriter.flush() nor StringWriter.close() seem to have the desired effect.

question from:https://stackoverflow.com/questions/3738095/how-do-you-empty-a-stringwriter-in-java

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

How about calling getBuffer().setLength(0)?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...