本文整理汇总了Java中org.apache.commons.lang3.StringUtils.replaceOnce方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.replaceOnce方法的具体用法?Java StringUtils.replaceOnce怎么用?Java StringUtils.replaceOnce使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.replaceOnce方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMessage
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static String getMessage(CodeTemp templ, String... params) {
String regContent = templ.getTemp();
int index = 0;
while (regContent.indexOf("{}") >= 0) {
if (ArrayUtils.isEmpty(params) || params.length <= index) {
if (regContent.indexOf("{}") >= 0) {
regContent = regContent.replaceAll("\\{\\}", "");
}
break;
}
regContent = StringUtils.replaceOnce(regContent, "{}", params[index]);
index++;
}
return regContent;
}
示例2: expand
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
protected Path expand(final Path remote, final String format) throws BackgroundException {
if(remote.getAbsolute().startsWith(format)) {
return new Path(StringUtils.replaceOnce(remote.getAbsolute(), format, workdir.getAbsolute()),
remote.getType());
}
return remote;
}
示例3: replaceWithSysPropUserHome
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static String[] replaceWithSysPropUserHome(final String[] pathArray) {
if (ArrayUtils.isEmpty(pathArray)) {
return pathArray;
}
final String SYS_PROP_USER_HOME = System.getProperty("user.home");
for (int index = 0; index < pathArray.length; index++) {
if (StringUtils.startsWith(pathArray[index], "~")) {
pathArray[index] = StringUtils.replaceOnce(pathArray[index], "~", SYS_PROP_USER_HOME);
}
}
return pathArray;
}
示例4: changeProtocolToHttpsIfNeeded
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String changeProtocolToHttpsIfNeeded(final String repositoryUrl) {
if (!StringUtils.isBlank(repositoryUrl) && repositoryUrl.startsWith(GIT_PROTOCOL)) {
return StringUtils.replaceOnce(repositoryUrl.replace(":", "/"), GIT_PROTOCOL, HTTPS_PROTOCOL);
}
return repositoryUrl;
}
示例5: handle
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
protected String handle(String input, String second, String third) {
return StringUtils.replaceOnce(input, second, third);
}