问题:
This question already has an answer here: 这个问题已经在这里有了答案:
- Clearing a string buffer/builder after loop 8 answers 循环 8回答 后清除字符串缓冲区/生成器
I'm using a StringBuilder in a loop and every x iterations I want to empty it and start with an empty StringBuilder
, but I can't see any method similar to the .NET StringBuilder.Clear in the documentation, just the delete method which seems overly complicated. 我在循环中使用StringBuilder ,每隔x次迭代,我想将其清空并从一个空的StringBuilder
开始,但是在文档中看不到任何类似于.NET StringBuilder.Clear的方法,只是删除方法似乎过于复杂。
So what is the best way to clean out a StringBuilder
in Java? 那么用Java清理StringBuilder
的最佳方法是什么?
解决方案:
参考一: https://stackoom.com/question/LmoC/如何清除或清空StringBuilder-重复参考二: https://oldbug.net/q/LmoC/How-can-I-clear-or-empty-a-StringBuilder-duplicate
来源:oschina
链接:https://my.oschina.net/u/4438370/blog/4404878