public class Utils extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
TAG_classpath
已过时。
2.7
|
| 构造器和说明 |
|---|
Utils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
annoAlias(String v1,
String v2)
获取注解别名
|
static String |
appFolder()
应用所在文件夹
|
static <T> List<T> |
asList(T[] ary)
转为一个可变 List(Arrays.asList 不可变)
|
static Future<?> |
async(Runnable task)
异步执行
|
static void |
bindTo(Function<String,String> source,
Object target)
将 source:((k)->v) 数据,绑定到 target:bean
|
static void |
bindTo(Map<String,String> source,
Object target)
将 source:Map 数据,绑定到 target:bean
|
static void |
bindTo(Properties source,
Object target)
将 source:Properties 数据,绑定到 target:bean
|
static File |
buildExt(String extend,
boolean autoMake)
已过时。
2.7
|
static Properties |
buildProperties(String txt)
根据txt加载配置集
|
static <T> T |
firstOrNull(List<T> list)
获取第一项或者null
|
static ClassLoader |
getClassLoader()
获取ClassLoader
|
static ClassLoader |
getContextClassLoader()
获取当前线程的ClassLoader
|
static File |
getFile(String uri)
获取文件
|
static File |
getFolderAndMake(String uri,
boolean autoMake)
获取目录并生成
|
static String |
getFullStackTrace(Throwable ex)
获取异常的完整内容
|
static URL |
getResource(ClassLoader classLoader,
String name)
已过时。
2.2
|
static URL |
getResource(String name)
已过时。
2.2
|
static String |
getResourceAsString(ClassLoader classLoader,
String name,
String charset)
已过时。
2.2
|
static String |
getResourceAsString(String name)
已过时。
2.2
|
static String |
getResourceAsString(String name,
String charset)
已过时。
2.2
|
static Enumeration<URL> |
getResources(ClassLoader classLoader,
String name)
已过时。
2.2
|
static Enumeration<URL> |
getResources(String name)
已过时。
2.2
|
static String |
guid()
生成UGID
|
static boolean |
hasClass(SupplierEx<Class<?>> test)
已过时。
2.2
|
static <T> T |
injectProperties(T obj,
Properties propS)
注入属性
|
static boolean |
isBlank(String s)
检查字符串是否为空白
|
static boolean |
isEmpty(Collection s)
检查集合是否为空
|
static boolean |
isEmpty(Map s) |
static boolean |
isEmpty(String s)
检查字符串是否为空
|
static <T> boolean |
isEmpty(T[] array) |
static boolean |
isNotBlank(String s)
检查字符串是否不为空白
|
static boolean |
isNotEmpty(Collection s)
检查集合是否非空
|
static boolean |
isNotEmpty(String s)
检查字符串是否为非空
|
static boolean |
isProxyClass(Class<?> clz)
是否为 Solon 代理类
|
static boolean |
isWhitespace(int c)
检查是否为空白字符
|
static Class<?> |
loadClass(ClassLoader classLoader,
String className)
已过时。
2.2
|
static Class<?> |
loadClass(String className)
已过时。
2.2
|
static Properties |
loadProperties(String url)
根据本地资源url加载配置集
|
static Properties |
loadProperties(URL url)
根据url加载配置集
|
static ReentrantLock |
locker()
公共锁(仅用于一次性的场景)
|
static String |
md5(String str)
生成MD5
|
static String |
mime(String fileName)
获取MIME
|
static <T> T |
newInstance(Class<?> clz)
已过时。
2.2
|
static <T> T |
newInstance(Class<?> clz,
Properties prop)
已过时。
2.2
|
static <T> T |
newInstance(ClassLoader classLoader,
String className)
已过时。
2.2
|
static <T> T |
newInstance(ClassLoader classLoader,
String className,
Properties prop)
已过时。
2.2
|
static <T> T |
newInstance(String className)
已过时。
2.2
|
static <T> T |
newInstance(String className,
Properties prop)
已过时。
2.2
|
static String |
pid()
获取进程号
|
static boolean |
ping(String address)
Ping 一个地址
|
static Collection<String> |
resolvePaths(String pathExpr)
已过时。
2.0
|
static String |
snakeToCamel(String name)
蛇形转驼峰
|
static boolean |
throwableHas(Throwable ex,
Class<? extends Throwable> clz)
异常栈里是否存在某类异常
|
static String |
throwableToString(Throwable ex)
获取异常打印信息
|
static Throwable |
throwableUnwrap(Throwable ex)
解包异常
|
static <T> T[] |
toArray(List<T> list,
T[] a) |
static Locale |
toLocale(String lang) |
static <T extends OutputStream> |
transferTo(InputStream ins,
T out)
已过时。
2.4
|
static byte[] |
transferToBytes(InputStream ins)
已过时。
2.4
|
static String |
transferToString(InputStream ins)
已过时。
2.4
|
static String |
transferToString(InputStream ins,
String charset)
已过时。
2.4
|
static String |
trimDuplicates(String str,
char c)
去除重复字符
|
@Deprecated public static final String TAG_classpath
public static ReentrantLock locker()
public static boolean ping(String address) throws Exception
address - (例:192.168.1.1 或 192.168.1.1:8080)Exceptionpublic static <T> List<T> asList(T[] ary)
public static boolean isProxyClass(Class<?> clz)
public static String guid()
@Deprecated public static Collection<String> resolvePaths(String pathExpr)
pathExpr - 路径表达式public static boolean throwableHas(Throwable ex, Class<? extends Throwable> clz)
ex - 异常栈clz - 要检测的异常类public static boolean isEmpty(String s)
s - 字符串public static boolean isEmpty(Collection s)
s - 集合public static boolean isEmpty(Map s)
public static <T> boolean isEmpty(T[] array)
public static boolean isNotEmpty(String s)
s - 字符串public static boolean isNotEmpty(Collection s)
s - 集合public static boolean isBlank(String s)
s - 字符串public static boolean isNotBlank(String s)
s - 字符串public static boolean isWhitespace(int c)
c - 字符public static <T> T firstOrNull(List<T> list)
public static <T> T[] toArray(List<T> list, T[] a)
@Deprecated public static boolean hasClass(SupplierEx<Class<?>> test)
@Deprecated public static Class<?> loadClass(String className)
className - 类名称@Deprecated public static Class<?> loadClass(ClassLoader classLoader, String className)
classLoader - 类加载器className - 类名称@Deprecated public static <T> T newInstance(String className)
className - 类名称@Deprecated public static <T> T newInstance(String className, Properties prop)
@Deprecated public static <T> T newInstance(ClassLoader classLoader, String className)
classLoader - 类加载器className - 类名称@Deprecated public static <T> T newInstance(ClassLoader classLoader, String className, Properties prop)
@Deprecated public static <T> T newInstance(Class<?> clz) throws Exception
Exception@Deprecated public static <T> T newInstance(Class<?> clz, Properties prop) throws Exception
Exception@Deprecated public static Enumeration<URL> getResources(String name) throws IOException
name - 资源名称IOException@Deprecated public static Enumeration<URL> getResources(ClassLoader classLoader, String name) throws IOException
classLoader - 类加载器name - 资源名称IOException@Deprecated public static URL getResource(String name)
name - 资源名称@Deprecated public static URL getResource(ClassLoader classLoader, String name)
classLoader - 类加载器name - 资源名称@Deprecated public static String getResourceAsString(String name) throws IOException
name - 资源名称IOException@Deprecated public static String getResourceAsString(String name, String charset) throws IOException
name - 资源名称charset - 编码IOException@Deprecated public static String getResourceAsString(ClassLoader classLoader, String name, String charset) throws IOException
classLoader - 类加载器name - 资源名称charset - 编码IOException@Deprecated public static String transferToString(InputStream ins) throws IOException
IOException@Deprecated public static String transferToString(InputStream ins, String charset) throws IOException
ins - 输入流charset - 字符集IOException@Deprecated public static byte[] transferToBytes(InputStream ins) throws IOException
ins - 输入流IOException@Deprecated public static <T extends OutputStream> T transferTo(InputStream ins, T out) throws IOException
ins - 输入流out - 输出流IOExceptionpublic static Properties loadProperties(URL url)
url - 资源地址public static Properties loadProperties(String url)
url - 资源地址public static Properties buildProperties(String txt)
txt - 资源内容public static <T> T injectProperties(T obj,
Properties propS)
obj - 对象propS - 属性集public static String appFolder()
public static File getFolderAndMake(String uri, boolean autoMake)
uri - 目录地址(支持相对位置)autoMake - 是否自动创建@Deprecated public static File buildExt(String extend, boolean autoMake)
extend - 扩展目录autoMake - 是否自动创建public static void bindTo(Map<String,String> source, Object target)
public static void bindTo(Properties source, Object target)
public static void bindTo(Function<String,String> source, Object target)
public static ClassLoader getContextClassLoader()
public static ClassLoader getClassLoader()
public static String pid()
Copyright © 2024. All rights reserved.