public final class Fun extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
blank(CharSequence str)
检测字符串是否为空白。
|
static boolean |
blankAll(CharSequence... strs)
检测字符串是否全部为空
|
static boolean |
contains(CharSequence str,
CharSequence searchStr)
查找字符串
|
static boolean |
containsAny(CharSequence str,
CharSequence... searchStrs)
查找指定字符串是否包含指定字符列表中的任意一个字符
|
static String |
date()
根据格式化参数返回时间字符串
|
static String |
date(long timestamp)
根据格式化参数返回时间字符串
|
static String |
date(String pattern)
根据格式化参数返回时间字符串
|
static String |
date(String pattern,
long timestamp)
根据格式化参数,时间戳参数,返回时间字符串
|
static boolean |
empty(CharSequence str)
检测字符串是否为空。
|
static boolean |
emptyAll(CharSequence... strs)
检测字符串是否全部为空
|
static <T> boolean |
emptyArray(T[] array)
检测数组是否为空
|
static boolean |
endWith(CharSequence str,
CharSequence suffix)
是否以指定字符串结尾
|
static boolean |
endWithIgnoreCase(CharSequence str,
CharSequence suffix)
是否以指定字符串结尾,忽略大小写
|
static boolean |
equals(CharSequence str1,
CharSequence str2)
比较两个字符串
|
static boolean |
equalsIgnoreCase(CharSequence str1,
CharSequence str2)
比较两个字符串(大小写不敏感)
|
static long |
freeMemory()
返回系统空闲内存
|
static long |
freeMemory(String sizeFormat)
格式化返回系统当前空闲内存
|
static int |
intval(String str)
字符串转整型
如果是
null 或者 "",返回 0 |
static long |
longval(String str)
字符串转整型
如果是
null 或者 "",返回 0 |
static String |
ltrim(CharSequence str)
除去字符串左侧的空白
|
static long |
maxMemory()
返回系统最大内存
|
static long |
maxMemory(String sizeFormat)
格式化返回系统当前最大内存
|
static long |
microtime()
返回当前 Unix 时间戳(毫秒)
|
static String |
rtrim(CharSequence str)
除去字符串右侧的空白
|
static boolean |
startWith(CharSequence str,
CharSequence prefix)
是否以指定字符串开头
|
static boolean |
startWithIgnoreCase(CharSequence str,
CharSequence prefix)
是否以指定字符串开头,忽略大小写
|
static int |
strlen(CharSequence str)
获取字符串的长度,如果为 null 返回 0
|
static long |
strtotime()
返回当前默认时间戳
|
static long |
strtotime(String dateString)
通用格式日期时间字符串自动转换时间戳
|
static long |
strtotime(String dateString,
Long timestamp)
以提供的时间戳为基准,返回简单表达式计算后的时间戳
|
static long |
time()
返回当前 Unix 时间戳(秒)
|
static int |
toInt(String str)
字符串转整型
如果是
null 或者 "",返回 0 |
static int |
toInt(String str,
int defalutValue)
字符串转整型
如果是
null 或者 "" 或者失败,返回默认值 |
static long |
toLong(String str)
字符串转整型
如果是
null 或者 "",返回 0 |
static long |
toLong(String str,
long defalutValue)
字符串转整型
如果是
null 或者 "" 或者失败,返回默认值 |
static long |
totalMemory()
返回系统当前占用内存
|
static long |
totalMemory(String sizeFormat)
格式化返回系统当前占用内存
|
static String |
trim(CharSequence str)
除去字符串头尾部的空白,如果字符串是
null,依然返回null。 |
static String |
trimToEmpty(CharSequence str)
除去字符串头尾部的空白
如果是
null,返回 "" |
static String |
trimToNull(CharSequence str)
除去字符串头尾部的空白
如果字符串是
null 或者 "" ,返回 null。 |
static long |
usedMemory()
返回系统当前使用内存
|
static long |
usedMemory(String sizeFormat)
格式化返回系统使用空闲内存
|
public static long time()
public static long microtime()
public static long freeMemory()
public static long maxMemory()
public static long usedMemory()
public static long totalMemory()
public static long freeMemory(String sizeFormat)
sizeFormat - 格式化单位public static long usedMemory(String sizeFormat)
sizeFormat - 格式化单位public static long maxMemory(String sizeFormat)
sizeFormat - 格式化单位public static long totalMemory(String sizeFormat)
sizeFormat - 格式化单位public static boolean blank(CharSequence str)
str - 待检测字符串public static boolean blankAll(CharSequence... strs)
strs - 字符串列表public static boolean empty(CharSequence str)
str - 待检测字符串public static boolean emptyAll(CharSequence... strs)
strs - 字符串列表public static <T> boolean emptyArray(T[] array)
T - Tarray - 数组public static String trim(CharSequence str)
null,依然返回null。
和String.trim不同,此方法使用CharUtil.isBlankChar 来判定空白, 因而可以除去英文字符集之外的其它空白,如中文空格。
str - 待处理字符串public static String ltrim(CharSequence str)
str - 待处理字符串public static String rtrim(CharSequence str)
str - 待处理字符串public static String trimToEmpty(CharSequence str)
null,返回 ""str - 待处理字符串public static String trimToNull(CharSequence str)
null 或者 "" ,返回 null。str - 待处理字符串public static int toInt(String str)
null 或者 "",返回 0str - 字符串public static int toInt(String str, int defalutValue)
null 或者 "" 或者失败,返回默认值str - 字符串defalutValue - 默认值public static int intval(String str)
null 或者 "",返回 0str - 字符串public static long longval(String str)
null 或者 "",返回 0str - 字符串public static long toLong(String str)
null 或者 "",返回 0str - 字符串public static boolean contains(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 startWith(CharSequence str, CharSequence prefix)
str - 被监测字符串prefix - 开头字符串public static boolean startWithIgnoreCase(CharSequence str, CharSequence prefix)
str - 被监测字符串prefix - 开头字符串public static boolean endWith(CharSequence str, CharSequence suffix)
str - 被监测字符串suffix - 结尾字符串public static boolean endWithIgnoreCase(CharSequence str, CharSequence suffix)
str - 被监测字符串suffix - 结尾字符串public static int strlen(CharSequence str)
str - 字符串public static long toLong(String str, long defalutValue)
null 或者 "" 或者失败,返回默认值str - 字符串defalutValue - 默认值public static String date()
public static String date(long timestamp)
timestamp - 时间戳public static String date(String pattern, long timestamp)
pattern - 日期时间格式timestamp - 时间戳public static long strtotime()
public static long strtotime(String dateString)
dateString - 日期时间字符串Copyright © 2020. All rights reserved.