public class Fun extends FunBase
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
base64Decode(String str)
base64Decode
|
static String |
base64Encode(String str)
base64Encode
|
static String |
base64UrlSafeDecode(String str)
base64URLDecode
|
static String |
base64UrlSafeEncode(String str)
base64URLEncode
会将 +、/ 替换为 -、_
|
static boolean |
blank(CharSequence str)
检测字符串是否为空白
空白包含:null、""、" "、以及不可见字符如缩紧
|
static boolean |
blankAll(CharSequence... strs)
检测字符串列表,是否全部为空白
|
static boolean |
blankAny(CharSequence... strs)
检测字符串列表,是否包含空白,包含任意一个空白返回 true
空白包含:null、""、" "、以及不可见字符如缩紧
|
static byte[] |
bytes(CharSequence str)
字符串获取 Bytes
|
static byte[] |
bytes(CharSequence str,
Charset charset)
字符串获取 Bytes
|
static byte[] |
bytes(CharSequence str,
String charset)
字符串获取 Bytes
|
static boolean |
contains(CharSequence str,
CharSequence searchStr)
查找字符串是否包含指定字符串
|
static boolean |
containsAny(CharSequence str,
CharSequence... searchStrs)
查找指定字符串,是否包含指定字符列表中的任意一个字符串
|
static boolean |
containsIgnoreCase(CharSequence str,
CharSequence searchStr)
查找字符串是否包含指定字符串,忽略大小写
|
static String |
date()
返回默认日期时间字符串
默认格式:yyyy-MM-dd HH:mm:ss
|
static String |
date(long timestamp)
根据时间戳,返回默认日期时间字符串
默认格式:yyyy-MM-dd HH:mm:ss
|
static String |
date(String pattern)
根据格式化参数返回日期时间字符串
|
static String |
date(String pattern,
long timestamp)
根据格式化参数,时间戳参数,返回时间字符串
|
static boolean |
empty(CharSequence str)
检测字符串是否为空
空包含 null、空字符串 ""
|
static boolean |
empty(Collection<?> collection)
检测 Collection 是否为空
|
static boolean |
empty(Map<?,?> map)
检测 Map 是否为空
|
static boolean |
empty(Object object)
检测是否为空,(可匹配单一对象)
如果对象为 null,返回 true
如果对象为数组,判断数组长度是否为 0
如果对象为字符串,判断字符串长度是否为 0
如果对象为数值类型,判断是否为 0
如果对象为布尔类型,判断是否为 false
其他情况,默认返回 false
|
static <T> boolean |
empty(T[] array)
检测数组为空(范型)
|
static boolean |
emptyAll(CharSequence... strs)
检测字符串列表,是否全部为空
|
static boolean |
emptyAny(CharSequence... strs)
检测字符串列表,是否包含有空值,包含任意一个返回 true
|
static boolean |
endsWith(CharSequence str,
CharSequence suffix)
是否以指定字符串结尾
如果给定的字符串和开头字符串都为 null 则返回 true ,否则任意一个值为 null 返回 false
如果给定的字符串不为 null,suffix 字符串为 "" 空字符串,返回true
|
static boolean |
endsWithIgnoreCase(CharSequence str,
CharSequence suffix)
是否以指定字符串结尾,忽略大小写
|
static boolean |
equals(CharSequence str1,
CharSequence str2)
比较两个字符串
|
static boolean |
equalsIgnoreCase(CharSequence str1,
CharSequence str2)
比较两个字符串,忽略大小写
|
static long |
freeMemoryMb()
返回系统空闲堆内存,单位MB
|
static long |
idDecode(String hash)
Hashid 解密
|
static long |
idDecode(String hash,
int minLength)
Hashid 解密
|
static long |
idDecode(String hash,
String salt)
Hashid 解密
|
static long |
idDecode(String hash,
String salt,
int minLength)
Hashid 解密
|
static String |
idEncode(long id)
Hashid 加密
|
static String |
idEncode(long id,
int minLength)
Hashid 加密
|
static String |
idEncode(long id,
String salt)
Hashid 加密
|
static String |
idEncode(long id,
String salt,
int minLength)
Hashid 加密
|
static int |
indexOf(CharSequence str,
CharSequence searchStr)
查找字符串,返回索引位置
|
static int |
indexOf(CharSequence str,
CharSequence searchStr,
int start)
查找字符串,返回索引位置
|
static int |
indexOfIgnoreCase(CharSequence str,
CharSequence searchStr)
查找字符串,返回索引位置,忽略大小写
|
static int |
indexOfIgnoreCase(CharSequence str,
CharSequence searchStr,
int start)
查找字符串,返回索引位置,忽略大小写
|
static <T> String |
join(Iterable<?> iterable,
String separator)
以 separator 为分隔符转换为字符串,支持字符串类容器
|
static String |
join(Iterator<?> iterator,
String separator)
以 separator 为分隔符转换为字符串,支持字符串容器
|
static <T> String |
join(T[] array,
CharSequence separator)
以 separator 为分隔符将数组转换为字符串(范型)
|
static String |
left(String str,
int length)
截取字符串左侧指定长度的子串
|
static int |
length(CharSequence str)
获取字符串的字符长度,如果为 null 返回 0
使用 String.length 方法, 中英文数字均是 1
|
static String |
ltrim(CharSequence str)
除去字符串左侧的空白
|
static boolean |
matches(Pattern pattern,
CharSequence content)
字符串是否匹配正则
|
static boolean |
matches(String regex,
CharSequence content)
字符串是否匹配正则
|
static long |
maxMemoryMb()
返回系统最大堆内存(-Xmx),单位MB
|
static String |
md5(String str)
MD5
|
static long |
microtime()
返回当前 Unix 时间戳(毫秒)
|
static String |
padLeft(CharSequence str,
int length)
左侧填充字符串到指定长度,使用默认空格填充
|
static String |
padLeft(CharSequence str,
int length,
char padChar)
右侧填充字符串到最小长度,使用单一字符填充
|
static String |
padLeft(CharSequence str,
int length,
String padStr)
左侧填充字符串到指定长度
|
static String |
padRight(CharSequence str,
int length)
右侧填充字符串到指定长度。
|
static String |
padRight(CharSequence str,
int length,
char padChar)
右侧填充字符串到指定长度。
|
static String |
padRight(CharSequence str,
int length,
String padStr)
右侧填充字符串到指定长度
|
static int |
random()
获得指定范围内的随机数
默认 [0,Integer.MAX_VALUE)
|
static int |
randomInt(int max)
获得指定范围内的随机数 [0, max)
|
static long |
randomLong(long max)
获得指定范围内的随机数 [0, max)
|
static String |
randomString(int length)
获得一个指定长度随机的字符串(只包含数字和字符)
|
static String |
randomStringChar(int length)
获得一个指定长度只包含字符的随机字符串
|
static String |
randomStringExcepts(int length,
String... excepts)
获得一个指定长度随机的字符串,排除指定的字符串列表集
|
static String |
randomStringNumber(int length)
获得一个指定长度只包含数字的随机字符串
|
static List<String> |
regexMatch(Pattern pattern,
CharSequence content)
获得匹配字符串的所有分组
分组 0,表示全匹配的信息
|
static String |
regexMatch(Pattern pattern,
CharSequence content,
int groupIndex)
获得匹配字符串的指定分组
分组 0,表示全匹配的信息
|
static List<String> |
regexMatch(String regex,
CharSequence content)
获得匹配字符串的所有分组
|
static String |
regexMatch(String regex,
CharSequence content,
int groupIndex)
获得匹配字符串的指定分组
分组 0,表示全匹配的信息
|
static String |
remove(CharSequence str,
CharSequence remove)
移除字符串中所有给定字符串
|
static String |
removeAny(CharSequence str,
char... chars)
去除字符串中指定的多个字符集
|
static String |
removeAny(CharSequence str,
CharSequence... removes)
移除字符串中所有给定字符串列表
|
static String |
removeLines(CharSequence str)
去除字符串中换行符
|
static String |
removePrefix(CharSequence str,
CharSequence remove)
移除字符串左侧中所有给定字符串
|
static String |
removePrefixComplete(CharSequence str,
CharSequence remove)
完整的移除字符串左侧中所有给定字符串
|
static String |
removeSuffix(CharSequence str,
CharSequence remove)
移除字符串右侧中所有给定字符串
|
static String |
removeSuffixComplete(CharSequence str,
CharSequence remove)
完整的移除字符串右侧中所有给定字符串
|
static String |
repeat(char ch,
int repeat)
重复字符到指定次数
|
static String |
repeat(CharSequence str,
int repeat)
重复字符串到指定次数
|
static String |
replace(CharSequence str,
CharSequence searchStr,
CharSequence replaceStr)
字符串替换
|
static String |
replaceIgnoreCase(CharSequence str,
CharSequence searchStr,
CharSequence replaceStr)
字符串替换,忽略大小写
|
static String |
reverse(String str)
反转字符串
|
static String |
right(String str,
int length)
截取字符串右侧指定长度的子串
|
static String |
rtrim(CharSequence str)
除去字符串右侧的空白
|
static String |
sha1(String str)
SHA1
|
static String |
sha256(String str)
SHA256
|
static String |
sha384(String str)
SHA384
|
static String |
sha512(String str)
SHA512
|
static String[] |
split(CharSequence str)
分割字符串为数组
|
static String[] |
split(CharSequence str,
char separator)
分割字符串为数组
|
static String[] |
split(CharSequence str,
CharSequence separator)
分割字符串为数组
|
static List<String> |
splitToList(CharSequence str)
分割字符串为列表
默认以空白字符分割。
|
static List<String> |
splitToList(CharSequence str,
char separator)
分割字符串为列表
默认以空白字符分割。
|
static List<String> |
splitToList(CharSequence str,
CharSequence separator)
分割字符串为列表
|
static String[] |
splitTrim(CharSequence str)
分割字符串为数组
默认以空白字符分割。
|
static String[] |
splitTrim(CharSequence str,
char separator)
分割字符串为数组
默认以空白字符分割。
|
static String[] |
splitTrim(CharSequence str,
CharSequence separator)
分割字符串为数组
|
static int[] |
splitTrimToInt(CharSequence str)
分割字符串为数组
默认以空白字符分割。
|
static int[] |
splitTrimToInt(CharSequence str,
CharSequence separator)
分割字符串为数组
默认以空白字符分割。
|
static List<String> |
splitTrimToList(CharSequence str)
分割字符串为列表
默认以空白字符分割。
|
static List<String> |
splitTrimToList(CharSequence str,
char separator)
分割字符串为列表
默认以空白字符分割。
|
static List<String> |
splitTrimToList(CharSequence str,
CharSequence separator)
分割字符串为列表
|
static long[] |
splitTrimToLong(CharSequence str,
CharSequence separator)
分割字符串为数组
默认以空白字符分割。
|
static short[] |
splitTrimToShort(CharSequence str,
CharSequence separator)
分割字符串为数组
默认以空白字符分割。
|
static boolean |
startsWith(CharSequence str,
CharSequence prefix)
检测字符串是否以指定字符串开头
如果给定的字符串和开头字符串都为 null 则返回 true ,否则任意一个值为 null 返回 false
如果给定的字符串不为 null,prefix 字符串为 "" 空字符串,返回true
|
static boolean |
startsWithIgnoreCase(CharSequence str,
CharSequence prefix)
是否以指定字符串开头,忽略大小写
|
static long |
strtotime()
返回当前 Unix 时间戳
|
static long |
strtotime(String dateString)
将通用格式的日期时间字符串,自动为转换时间戳
|
static long |
strtotime(String expString,
Long timestamp)
以提供的时间戳为基准,返回简单表达式计算后的时间戳
|
static String |
substr(CharSequence str,
int start)
字符串截取,等同于 substring
|
static String |
substr(CharSequence str,
int start,
int length)
字符串截取
|
static String |
substring(CharSequence str,
int start)
字符串截取
|
static String |
substring(CharSequence str,
int start,
int end)
字符串截取
|
static long |
time()
返回当前 Unix 时间戳(秒)
|
static double |
toDouble(String str)
字符串转浮点型
如果是 null 或者 "" 或者异常,返回 0.0
|
static double |
toDouble(String str,
double defaultValue)
字符串转浮点型
如果是 null 或者 "" 或者异常,返回默认值
|
static float |
toFloat(String str)
字符串转浮点型
如果是 null 或者 "" 或者异常,返回 0.0
|
static float |
toFloat(String str,
float defaultValue)
字符串转浮点型
如果是 null 或者 "" 或者异常,返回默认值
|
static int |
toInt(String str)
字符串转整型
如果是 null 或者 "" 或者异常,返回 0
如果是小数,返回 0
|
static int |
toInt(String str,
int defaultValue)
字符串转整型
如果是 null 或者 "" 或者异常,返回默认值
|
static long |
toLong(String str)
字符串转整型
如果是 null 或者 "" 或异常,返回 0
|
static long |
toLong(String str,
long defaultValue)
字符串转整型
如果是 null 或者 "" 或者异常,返回默认值
|
static String |
toLowerCase(CharSequence str)
字符串转小写
|
static String |
toStr(CharSequence cs)
CharSequence 转 String
|
static String |
toStr(Object obj)
数组或对象转 String
|
static long |
totalMemoryMb()
返回系统当前已申请堆内存,单位MB
|
static String |
toUpperCase(CharSequence str)
字符串转大写
|
static String |
trim(CharSequence str)
除去字符串头尾部的空白,如果字符串是 null,依然返回 null
和 String.trim 不同,此方法使用 CharUtils.isBlankChar() 来判定空白
|
static String |
trim(CharSequence str,
CharSequence trimStr)
除去字符串两侧的指定字符串集合
如果 trimStr 为空,则默认使用空白符号
|
static String |
trimToDefault(CharSequence str,
String defaultStr)
除去字符串头尾部的空白,并处理 null 值。
|
static String |
trimToEmpty(CharSequence str)
除去字符串头尾部的空白,并处理 null 值
如果是 null,返回 ""
|
static String |
trimToNull(CharSequence str)
除去字符串头尾部的空白,并处理 null 和空字符串 ""
如果字符串是 null 或者 "" ,返回 null
|
static String |
urlNormalize(String url)
自动格式化补齐 HTTP(s) URL,如缺少协议头
|
static URL |
urlParse(String url)
安全的解析 HTTP(s) URL,会对 URL 进行验证与格式化,返回 URL 实例
|
static boolean |
urlVerify(String url)
验证 HTTP(s) 格式
|
static long |
usedMemoryMb()
返回系统当前已使用堆内存,单位MB
|
base64Encode, base64UrlSafeEncode, empty, empty, empty, empty, empty, empty, empty, empty, empty, empty, empty, empty, freeMemory, freeMemoryByte, join, join, join, join, join, join, join, join, maxMemory, maxMemoryByte, md5, randomInt, randomInt, randomLong, randomLong, sha1, sha256, sha384, sha512, totalMemory, totalMemoryByte, usedMemory, usedMemoryBytepublic static long time()
public static long microtime()
public static long freeMemoryMb()
public static long maxMemoryMb()
public static long usedMemoryMb()
public static long totalMemoryMb()
public static byte[] bytes(CharSequence str)
str - 字符串public static byte[] bytes(CharSequence str, Charset charset)
str - 字符串charset - 字符集public static byte[] bytes(CharSequence str, String charset)
str - 字符串charset - 字符集public static boolean empty(Object object)
如果对象为 null,返回 true 如果对象为数组,判断数组长度是否为 0 如果对象为字符串,判断字符串长度是否为 0 如果对象为数值类型,判断是否为 0 如果对象为布尔类型,判断是否为 false 其他情况,默认返回 false
object - 数组public static boolean empty(CharSequence str)
空包含 null、空字符串 ""
str - 待检测字符串public static <T> boolean empty(T[] array)
T - Tarray - 数组public static boolean empty(Map<?,?> map)
map - 列表public static boolean empty(Collection<?> collection)
collection - 集合public static boolean emptyAny(CharSequence... strs)
strs - 字符串列表public static boolean emptyAll(CharSequence... strs)
strs - 字符串列表public static boolean blank(CharSequence str)
空白包含:null、""、" "、以及不可见字符如缩紧
str - 待检测字符串public static boolean blankAny(CharSequence... strs)
空白包含:null、""、" "、以及不可见字符如缩紧
strs - 字符串列表public static boolean blankAll(CharSequence... strs)
strs - 字符串列表public static boolean matches(String regex, CharSequence content)
regex - 正则表达式字符串content - 字符串public static boolean matches(Pattern pattern, CharSequence content)
pattern - 正则表达式content - 字符串public static String trim(CharSequence str)
和 String.trim 不同,此方法使用 CharUtils.isBlankChar() 来判定空白
str - 待处理字符串public static String ltrim(CharSequence str)
str - 待处理字符串public static String rtrim(CharSequence str)
str - 待处理字符串public static String trim(CharSequence str, CharSequence trimStr)
如果 trimStr 为空,则默认使用空白符号
str - 待处理字符串trimStr - 需要处理的字符串集合public static String trimToEmpty(CharSequence str)
如果是 null,返回 ""
str - 待处理字符串public static String trimToDefault(CharSequence str, String defaultStr)
str - 待处理字符串defaultStr - 默认值public static String trimToNull(CharSequence str)
如果字符串是 null 或者 "" ,返回 null
str - 待处理字符串public static int toInt(String str)
如果是 null 或者 "" 或者异常,返回 0 如果是小数,返回 0
str - 字符串public static int toInt(String str, int defaultValue)
如果是 null 或者 "" 或者异常,返回默认值
str - 字符串defaultValue - 默认值public static float toFloat(String str)
如果是 null 或者 "" 或者异常,返回 0.0
str - 字符串public static float toFloat(String str, float defaultValue)
如果是 null 或者 "" 或者异常,返回默认值
str - 字符串defaultValue - 默认值public static double toDouble(String str)
如果是 null 或者 "" 或者异常,返回 0.0
str - 字符串public static double toDouble(String str, double defaultValue)
如果是 null 或者 "" 或者异常,返回默认值
str - 字符串defaultValue - 默认值public static long toLong(String str)
如果是 null 或者 "" 或异常,返回 0
str - 字符串public static long toLong(String str, long defaultValue)
如果是 null 或者 "" 或者异常,返回默认值
str - 字符串defaultValue - 默认值public static boolean contains(CharSequence str, CharSequence searchStr)
str - 字符串searchStr - 被查找的字符串public static boolean containsIgnoreCase(CharSequence str, CharSequence searchStr)
str - 字符串searchStr - 被查找的字符串public static boolean containsAny(CharSequence str, CharSequence... searchStrs)
str - 指定字符串searchStrs - 被查找的字符串数组public static boolean equals(CharSequence str1, CharSequence str2)
str1 - 要比较的字符串1str2 - 要比较的字符串2public static boolean equalsIgnoreCase(CharSequence str1, CharSequence str2)
str1 - 要比较的字符串1str2 - 要比较的字符串2public static boolean startsWith(CharSequence str, CharSequence prefix)
如果给定的字符串和开头字符串都为 null 则返回 true ,否则任意一个值为 null 返回 false 如果给定的字符串不为 null,prefix 字符串为 "" 空字符串,返回true
str - 被监测字符串prefix - 开头字符串public static boolean startsWithIgnoreCase(CharSequence str, CharSequence prefix)
str - 被监测字符串prefix - 开头字符串public static boolean endsWith(CharSequence str, CharSequence suffix)
如果给定的字符串和开头字符串都为 null 则返回 true ,否则任意一个值为 null 返回 false 如果给定的字符串不为 null,suffix 字符串为 "" 空字符串,返回true
str - 被监测字符串suffix - 结尾字符串public static boolean endsWithIgnoreCase(CharSequence str, CharSequence suffix)
str - 被监测字符串suffix - 结尾字符串public static int length(CharSequence str)
使用 String.length 方法, 中英文数字均是 1
str - 字符串public static String toLowerCase(CharSequence str)
str - 字符串public static String toUpperCase(CharSequence str)
str - 字符串public static String left(String str, int length)
str - 字符串length - 长度public static String right(String str, int length)
str - 字符串length - 长度public static int indexOf(CharSequence str, CharSequence searchStr)
str - 字符串searchStr - 查找字符串public static int indexOf(CharSequence str, CharSequence searchStr, int start)
str - 字符串searchStr - 查找字符串start - 起始位置public static int indexOfIgnoreCase(CharSequence str, CharSequence searchStr)
str - 字符串searchStr - 查找字符串public static int indexOfIgnoreCase(CharSequence str, CharSequence searchStr, int start)
str - 字符串searchStr - 查找字符串start - 起始位置public static String toStr(CharSequence cs)
cs - 字符串public static String repeat(char ch, int repeat)
ch - 字符repeat - 次数public static String repeat(CharSequence str, int repeat)
str - 字符串repeat - 次数public static String padLeft(CharSequence str, int length, char padChar)
str - 待填充字符串length - 长度padChar - 填充字符public static String padLeft(CharSequence str, int length)
str - 待填充字符串length - 长度public static String padLeft(CharSequence str, int length, String padStr)
str - 待填充字符串length - 长度padStr - 填充字符串public static String padRight(CharSequence str, int length, char padChar)
str - 待填充字符length - 长度padChar - 填充字符public static String padRight(CharSequence str, int length)
str - 待填充字符串length - 长度public static String padRight(CharSequence str, int length, String padStr)
str - 待填充字符串length - 长度padStr - 填充字符串public static String[] split(CharSequence str)
str - 字符串public static String[] split(CharSequence str, char separator)
str - 字符串separator - 分隔符public static String[] split(CharSequence str, CharSequence separator)
str - 字符串separator - 分割字符串public static List<String> splitToList(CharSequence str)
默认以空白字符分割。对分割后的值进行 trim ,并自动忽略空值
str - 字符串public static List<String> splitToList(CharSequence str, char separator)
默认以空白字符分割。对分割后的值进行 trim ,并自动忽略空值
str - 字符串separator - 分隔符public static List<String> splitToList(CharSequence str, CharSequence separator)
str - 字符串separator - 分割字符串public static String[] splitTrim(CharSequence str)
默认以空白字符分割。对分割后的值进行 trim ,并自动忽略空值
str - 字符串public static int[] splitTrimToInt(CharSequence str)
默认以空白字符分割。对分割后的值进行 trim ,并自动忽略空值
str - 字符串public static String[] splitTrim(CharSequence str, char separator)
默认以空白字符分割。对分割后的值进行 trim ,并自动忽略空值
str - 字符串separator - 分隔符public static String[] splitTrim(CharSequence str, CharSequence separator)
str - 字符串separator - 分割字符串public static int[] splitTrimToInt(CharSequence str, CharSequence separator)
默认以空白字符分割。对分割后的值进行 trim ,并自动忽略空值
str - 字符串separator - 分隔符public static long[] splitTrimToLong(CharSequence str, CharSequence separator)
默认以空白字符分割。对分割后的值进行 trim ,并自动忽略空值
str - 字符串separator - 分隔符public static short[] splitTrimToShort(CharSequence str, CharSequence separator)
默认以空白字符分割。对分割后的值进行 trim ,并自动忽略空值
str - 字符串separator - 分隔符public static List<String> splitTrimToList(CharSequence str)
默认以空白字符分割。对分割后的值进行 trim ,并自动忽略空值
str - 字符串public static List<String> splitTrimToList(CharSequence str, char separator)
默认以空白字符分割。对分割后的值进行 trim ,并自动忽略空值
str - 字符串separator - 分隔符public static List<String> splitTrimToList(CharSequence str, CharSequence separator)
str - 字符串separator - 分割字符串public static String substring(CharSequence str, int start)
str - 字符串start - 起始索引public static String substring(CharSequence str, int start, int end)
str - 字符串start - 起始索引end - 结束索引public static String substr(CharSequence str, int start)
str - 字符串start - 起始索引public static String substr(CharSequence str, int start, int length)
str - 字符串start - 起始索引length - 截取长度public static <T> String join(T[] array, CharSequence separator)
T - 范型array - 数组separator - 分隔符public static <T> String join(Iterable<?> iterable, String separator)
T - 范型iterable - 字符串容器separator - 分隔符public static String regexMatch(Pattern pattern, CharSequence content, int groupIndex)
分组 0,表示全匹配的信息
pattern - 正则表达式模式content - 字符串groupIndex - 分组public static List<String> regexMatch(Pattern pattern, CharSequence content)
分组 0,表示全匹配的信息
pattern - 正则表达式模式content - 字符串public static String regexMatch(String regex, CharSequence content, int groupIndex)
分组 0,表示全匹配的信息
regex - 正则表达式字符串content - 字符串groupIndex - 分组public static List<String> regexMatch(String regex, CharSequence content)
regex - 正则表达式字符串content - 字符串public static String join(Iterator<?> iterator, String separator)
iterator - 迭代器separator - 分隔符public static String replace(CharSequence str, CharSequence searchStr, CharSequence replaceStr)
str - 待替换的字符串searchStr - 查找字符串replaceStr - 替换字符串public static String replaceIgnoreCase(CharSequence str, CharSequence searchStr, CharSequence replaceStr)
str - 待替换的字符串searchStr - 查找字符串replaceStr - 替换字符串public static String remove(CharSequence str, CharSequence remove)
str - 字符串remove - 被移除的字符串public static String removePrefix(CharSequence str, CharSequence remove)
str - 字符串remove - 被移除的字符串public static String removePrefixComplete(CharSequence str, CharSequence remove)
str - 字符串remove - 被移除的字符串public static String removeSuffix(CharSequence str, CharSequence remove)
str - 字符串remove - 被移除的字符串public static String removeSuffixComplete(CharSequence str, CharSequence remove)
str - 字符串remove - 被移除的字符串public static String removeAny(CharSequence str, CharSequence... removes)
str - 字符串removes - 被移除的字符串,一个或多个public static String removeAny(CharSequence str, char... chars)
str - 字符串chars - 字符列表public static String removeLines(CharSequence str)
str - 字符串public static String date()
默认格式:yyyy-MM-dd HH:mm:ss
public static String date(long timestamp)
默认格式:yyyy-MM-dd HH:mm:ss
timestamp - 时间戳public static String date(String pattern, long timestamp)
pattern - 日期时间格式timestamp - 时间戳public static long strtotime()
public static long strtotime(String dateString)
dateString - 日期时间字符串public static long strtotime(String expString, Long timestamp)
expString - 时期时间字符串timestamp - 时间戳public static int random()
默认 [0,Integer.MAX_VALUE)
public static int randomInt(int max)
max - 限制随机数的范围public static long randomLong(long max)
max - 限制随机数的范围public static String randomString(int length)
length - 字符串的长度public static String randomStringExcepts(int length, String... excepts)
length - 字符串的长度excepts - 待排除列表public static String randomStringNumber(int length)
length - 字符串的长度public static String randomStringChar(int length)
length - 字符串的长度public static String base64Decode(String str)
str - Base64字符串public static String base64UrlSafeEncode(String str)
会将 +、/ 替换为 -、_
str - 字符串public static String base64UrlSafeDecode(String str)
str - Base64字符串public static String idEncode(long id)
id - IDpublic static String idEncode(long id, int minLength)
id - IDminLength - 最小长度public static String idEncode(long id, String salt)
id - IDsalt - 盐public static String idEncode(long id, String salt, int minLength)
id - IDminLength - 最小长度salt - 盐public static long idDecode(String hash)
hash - Hash字符串public static long idDecode(String hash, int minLength)
hash - Hash 字符串minLength - 最小长度public static long idDecode(String hash, String salt)
hash - Hash 字符串salt - 盐public static long idDecode(String hash, String salt, int minLength)
hash - Hash 字符串salt - 盐minLength - 最小长度public static URL urlParse(String url)
url - 字符串public static boolean urlVerify(String url)
url - URL 字符串Copyright © 2021. All rights reserved.