本文整理汇总了Java中org.apache.commons.lang3.StringUtils.replaceChars方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.replaceChars方法的具体用法?Java StringUtils.replaceChars怎么用?Java StringUtils.replaceChars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.replaceChars方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateRid
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Generates request id based on UID and SHA-256.
*
* @return request identity
*/
public static String generateRid() {
byte[] encode = Base64.getEncoder().encode(DigestUtils.sha256(UUID.randomUUID().toString()));
try {
String rid = new String(encode, StandardCharsets.UTF_8.name());
rid = StringUtils.replaceChars(rid, "+/=", "");
return StringUtils.right(rid, RID_LENGTH);
} catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
}
示例2: messageToString
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* 将message转换成string,并用空格取代回车符和引号.
*/
private String messageToString(Message message) {
String json = format.printToString(message);
return StringUtils.replaceChars(StringUtils.replaceChars(
StringUtils.left(json, MAX_REQUEST_BYTES_LENGTH), '\n', ' '),
'"', ' ');
}
示例3: normalizePath
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* 在Windows环境里,兼容Windows上的路径分割符,将 '/' 转回 '\'
*/
public static String normalizePath(String path) {
if (Platforms.FILE_PATH_SEPARATOR_CHAR == Platforms.WINDOWS_FILE_PATH_SEPARATOR_CHAR
&& StringUtils.indexOf(path, Platforms.LINUX_FILE_PATH_SEPARATOR_CHAR) != -1) {
return StringUtils.replaceChars(path, Platforms.LINUX_FILE_PATH_SEPARATOR_CHAR,
Platforms.WINDOWS_FILE_PATH_SEPARATOR_CHAR);
}
return path;
}
示例4: normalizeId
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* the Strings created by "newRandomId" are Base32 encoded,
* so they can be considered case-insensitive and also insensitive
* with regard to easily confused character like "1/I" or "0/O".
* This function returns a normalized version of an input String
* so that it would match an id generated by "newRandomId".
*/
public static String normalizeId(String id){
return StringUtils.replaceChars(StringUtils.upperCase(StringUtils.stripToNull(id)), "10 -", "IO");
}