本文整理匯總了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");
}