【发布时间】:2014-03-16 08:01:54
【问题描述】:
我想把空格换成“-”是什么方法
假设我的代码是
StringBuffer tokenstr=new StringBuffer();
tokenstr.append("technician education systems of the Cabinet has approved the following");
我要输出
"technician-education-systems-of-the-Cabinet-has-approved-the-following"
谢谢
【问题讨论】:
-
你可以使用
String.replaceAll() -
@user2573153 我使用的是字符串缓冲区而不是字符串。
-
你试过了吗?
-
StringBuffer.toString().replaceAll(...)? -
@RC 我没听明白?
标签: java replace stringbuffer