本文整理了Java中cn.hutool.core.util.StrUtil.subSufByLength()
方法的一些代码示例,展示了StrUtil.subSufByLength()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StrUtil.subSufByLength()
方法的具体详情如下:
包路径:cn.hutool.core.util.StrUtil
类名称:StrUtil
方法名:subSufByLength
[英]切割指定长度的后部分的字符串
StrUtil.subSufByLength("abcde", 3) = "cde"
StrUtil.subSufByLength("abcde", 0) = ""
StrUtil.subSufByLength("abcde", -5) = ""
StrUtil.subSufByLength("abcde", -1) = ""
StrUtil.subSufByLength("abcde", 5) = "abcde"
StrUtil.subSufByLength("abcde", 10) = "abcde"
StrUtil.subSufByLength(null, 3) = null
[中]切割指定长度的后部分的字符串
StrUtil.subSufByLength("abcde", 3) = "cde"
StrUtil.subSufByLength("abcde", 0) = ""
StrUtil.subSufByLength("abcde", -5) = ""
StrUtil.subSufByLength("abcde", -1) = ""
StrUtil.subSufByLength("abcde", 5) = "abcde"
StrUtil.subSufByLength("abcde", 10) = "abcde"
StrUtil.subSufByLength(null, 3) = null
代码示例来源:origin: looly/hutool
/**
* 补充字符串以满足最小长度
*
* <pre>
* StrUtil.padAfter(null, *, *);//null
* StrUtil.padAfter("1", 3, "ABC");//"1AB"
* StrUtil.padAfter("123", 2, "ABC");//"23"
* </pre>
*
* @param str 字符串,如果为<code>null</code>,按照空串处理
* @param minLength 最小长度
* @param padStr 补充的字符
* @return 补充后的字符串
* @since 4.3.2
*/
public static String padAfter(CharSequence str, int minLength, CharSequence padStr) {
if (null == str) {
return null;
}
final int strLen = str.length();
if (strLen == minLength) {
return str.toString();
} else if (strLen > minLength) {
return subSufByLength(str, minLength);
}
return str.toString().concat(repeatByLength(padStr, minLength - strLen));
}
代码示例来源:origin: looly/hutool
/**
* 补充字符串以满足最小长度
*
* <pre>
* StrUtil.padAfter(null, *, *);//null
* StrUtil.padAfter("1", 3, "ABC");//"1AB"
* StrUtil.padAfter("123", 2, "ABC");//"23"
* </pre>
*
* @param str 字符串,如果为<code>null</code>,按照空串处理
* @param minLength 最小长度
* @param padStr 补充的字符
* @return 补充后的字符串
* @since 4.3.2
*/
public static String padAfter(CharSequence str, int minLength, CharSequence padStr) {
if (null == str) {
return null;
}
final int strLen = str.length();
if (strLen == minLength) {
return str.toString();
} else if (strLen > minLength) {
return subSufByLength(str, minLength);
}
return str.toString().concat(repeatByLength(padStr, minLength - strLen));
}
代码示例来源:origin: cn.hutool/hutool-all
/**
* 补充字符串以满足最小长度
*
* <pre>
* StrUtil.padAfter(null, *, *);//null
* StrUtil.padAfter("1", 3, "ABC");//"1AB"
* StrUtil.padAfter("123", 2, "ABC");//"23"
* </pre>
*
* @param str 字符串,如果为<code>null</code>,按照空串处理
* @param minLength 最小长度
* @param padStr 补充的字符
* @return 补充后的字符串
* @since 4.3.2
*/
public static String padAfter(CharSequence str, int minLength, CharSequence padStr) {
if (null == str) {
return null;
}
final int strLen = str.length();
if (strLen == minLength) {
return str.toString();
} else if (strLen > minLength) {
return subSufByLength(str, minLength);
}
return str.toString().concat(repeatByLength(padStr, minLength - strLen));
}
内容来源于网络,如有侵权,请联系作者删除!