Package | Description |
---|---|
org.dromara.hutool.core.annotation |
注解包,提供增强型注解和注解工具类,处理包括:
注解元素(AnnotatedElement)上的注解。 |
org.dromara.hutool.core.bean |
Bean相关操作,包括Bean信息描述,Bean路径表达式、动态Bean、Bean工具等
|
org.dromara.hutool.core.classloader |
类加载相关封装和工具
|
org.dromara.hutool.core.codec |
编码解码封装编码封装
|
org.dromara.hutool.core.comparator |
各种比较器(Comparator)实现和封装
|
org.dromara.hutool.core.compress |
压缩解压封装
|
org.dromara.hutool.core.convert |
万能类型转换器以及各种类型转换的实现类,其中Convert为转换器入口,提供各种toXXX方法和convert方法
转换器是典型的策略模式应用,可自定义转换策略。 |
org.dromara.hutool.core.date |
日期封装,日期的核心为DateTime类,DateUtil提供日期操作的入口
|
org.dromara.hutool.core.exception |
特殊异常封装,同时提供异常工具ExceptionUtil
|
org.dromara.hutool.core.io |
IO相关封装和工具类,包括Inputstream和OutputStream实现类,工具包括流工具IoUtil、文件工具FileUtil和Buffer工具BufferUtil
|
org.dromara.hutool.core.io.resource |
针对ClassPath和文件中资源读取的封装,主要入口为工具类ResourceUtil
|
org.dromara.hutool.core.io.stream |
InputStream和OutputStream相关方法和类封装
|
org.dromara.hutool.core.io.watch |
基于JDK7+ WatchService的文件和目录监听封装,支持多级目录
|
org.dromara.hutool.core.map.multi |
多参数类型的Map实现,包括集合类型值的MultiValueMap和Table
MultiValueMap:一个键对应多个值的集合的实现,类似于树的结构。 |
org.dromara.hutool.core.net.url |
URL相关工具
|
org.dromara.hutool.core.pool |
对象池封装实现
整体参考了: https://github.com/DanielYWoo/fast-object-pool/ https://github.com/apache/commons-pool |
org.dromara.hutool.core.reflect |
提供反射相关功能对象和类
|
org.dromara.hutool.core.reflect.lookup |
MethodHandles.Lookup 创建封装,以根据不同的条件查找MethodHandles jdk8中如果直接调用 MethodHandles.lookup() 获取到的MethodHandles.Lookup 在调用findSpecial和unreflectSpecial
时会出现权限不够问题,抛出"no private access for invokespecial"异常,因此针对JDK8及JDK9+分别封装lookup方法。 |
org.dromara.hutool.core.reflect.method |
提供方法相关封装
|
org.dromara.hutool.core.spi |
服务提供接口SPI(Service Provider interface)机制相关封装,包括:
ListServiceLoader ,提供列表形式的服务定义
MapServiceLoader ,提供键值对形式的服务定义
|
org.dromara.hutool.core.thread |
提供线程及高并发封装,入口为ThreadUtil
|
org.dromara.hutool.core.util |
提供各种工具方法,按照归类入口为XXXUtil,如字符串工具StrUtil等
|
org.dromara.hutool.core.xml |
XML相关工具封装
|
org.dromara.hutool.cron |
定时任务模块,提供类Crontab表达式的定时任务,实现参考了Cron4j,同时可以支持秒级别的定时任务定义和年的定义(同时兼容Crontab、Cron4j、Quartz表达式)
定时任务模块由三部分组成: Scheduler 定时任务调度器,用于整体管理任务的增删、启停和触发运行。 |
org.dromara.hutool.crypto |
加密解密模块,实现了对JDK中加密解密算法的封装,入口为SecureUtil,实现了:
1.
|
org.dromara.hutool.db |
Hutool-db是一个在JDBC基础上封装的数据库操作工具类,通过包装,使用ActiveRecord思想操作数据库。
|
org.dromara.hutool.extra.compress |
基于commons-compress的压缩解压封装
支持包括:gzip, bzip2, xz, lzma, Pack200, DEFLATE, Brotli, DEFLATE64, ZStandard and Z, the archiver formats are 7z, ar, arj, cpio, dump, tar and zip等格式。 |
org.dromara.hutool.extra.ftp |
基于Apache Commons Net封装的FTP工具
|
org.dromara.hutool.extra.mail |
邮件封装,基于jakarta.mail库,入口为MailUtil
|
org.dromara.hutool.extra.management |
Management模块主要获取系统、JVM、内存、CPU等信息,以便动态监测系统状态
|
org.dromara.hutool.extra.pinyin |
拼音相关封装
createEngine getPinyin
PinyinEngineFactory =》 PinyinEngine =》 拼音
|
org.dromara.hutool.extra.qrcode |
二维码封装,基于zxing库,入口为QrCodeUtil
|
org.dromara.hutool.extra.spring |
Spring相关工具封装
|
org.dromara.hutool.extra.ssh |
Jsch封装,包括端口映射、SFTP封装等,入口为JschUtil
|
org.dromara.hutool.extra.template |
第三方模板引擎封装,提供统一的接口用于适配第三方模板引擎,提供:
TemplateEngine:模板引擎接口,用于不同引擎的实现。
|
org.dromara.hutool.extra.tokenizer |
中文分词封装
通过定义统一接口,适配第三方分词引擎 |
org.dromara.hutool.http |
Hutool-http针对JDK的HttpUrlConnection做一层封装,简化了HTTPS请求、文件上传、Cookie记忆等操作,使Http请求变得无比简单。
|
org.dromara.hutool.http.webservice |
Webservice客户端封装实现
|
org.dromara.hutool.json |
JSON(JavaScript Object Notation JavaScript对象表示法)封装
规范见:https://www.rfc-editor.org/rfc/rfc8259 包含以下组件: JSONObject: 使用键值对表示的数据类型,使用"{}"包围 JSONArray: 使用列表表示的数据类型,使用"[]"包围 JSONPrimitive:表示boolean、String、Number等原始类型 JSON封装主要包括JSON表示和JSON转换:
<-----JSONMapper----- <---JSONParser----
Java对象 <====================> JSON对象 <=================> JSON字符串
-----JSONMapper-----> ---JSONWriter---->
当然,为了高效转换,如果没有自定义需求,Java对象可以不通过JSON对象与JSON字符串转换:
JSONTokener:JSON字符串底层解析器,通过Stream方式读取JSON字符串并对不同字段自定义处理。 |
org.dromara.hutool.json.jwt |
JSON Web Token (JWT)封装
规范见:https://datatracker.ietf.org/doc/html/rfc7519 |
org.dromara.hutool.poi |
POI封装实现
Java针对MS Office的操作的库屈指可数,比较有名的就是Apache的POI库。 |
org.dromara.hutool.poi.excel.sax |
Sax方式操作Excel方式的封装
|
org.dromara.hutool.setting |
Setting模块主要针对Properties文件读写做封装,同时定义一套自己的配置文件规范,实现兼容性良好的配置工具。
|
org.dromara.hutool.socket |
Socket套接字相关工具类封装
|
Modifier and Type | Method and Description |
---|---|
static <T> T |
AnnotationUtil.getAnnotationValue(AnnotatedElement annotationEle,
Class<? extends Annotation> annotationType)
获取指定注解默认值
如果无指定的属性方法返回null |
static <T> T |
AnnotationUtil.getAnnotationValue(AnnotatedElement annotationEle,
Class<? extends Annotation> annotationType,
String propertyName)
获取指定注解属性的值
如果无指定的属性方法返回null |
static Map<String,Object> |
AnnotationUtil.getAnnotationValueMap(AnnotatedElement annotationEle,
Class<? extends Annotation> annotationType)
获取指定注解中所有属性值
如果无指定的属性方法返回null |
Modifier and Type | Class and Description |
---|---|
class |
BeanException
Bean异常
|
Modifier and Type | Method and Description |
---|---|
static <T> Class<T> |
ClassLoaderUtil.loadClass(String name)
加载类,通过传入类的字符串,返回其对应的类名,使用默认ClassLoader并初始化类(调用static模块内容和初始化static属性)
扩展 Class.forName(String, boolean, ClassLoader) 方法,支持以下几类类名的加载:
1、原始类型,例如:int
2、数组类型,例如:int[]、Long[]、String[]
3、内部类,例如:java.lang.Thread.State会被转为java.lang.Thread$State加载
|
static <T> Class<T> |
ClassLoaderUtil.loadClass(String name,
boolean isInitialized)
加载类,通过传入类的字符串,返回其对应的类名,使用默认ClassLoader
扩展 Class.forName(String, boolean, ClassLoader) 方法,支持以下几类类名的加载:
1、原始类型,例如:int
2、数组类型,例如:int[]、Long[]、String[]
3、内部类,例如:java.lang.Thread.State会被转为java.lang.Thread$State加载
|
static <T> Class<T> |
ClassLoaderUtil.loadClass(String name,
boolean isInitialized,
ClassLoader classLoader)
加载类,通过传入类的字符串,返回其对应的类名
此方法支持缓存,第一次被加载的类之后会读取缓存中的类 加载失败的原因可能是此类不存在或其关联引用类不存在 扩展 Class.forName(String, boolean, ClassLoader) 方法,支持以下几类类名的加载:
1、原始类型,例如:int
2、数组类型,例如:int[]、Long[]、String[]
3、内部类,例如:java.lang.Thread.State会被转为java.lang.Thread$State加载
|
static void |
JarClassLoader.loadJar(URLClassLoader loader,
File jarFile)
加载Jar文件到指定loader中
|
Modifier and Type | Method and Description |
---|---|
static String |
PunyCode.decode(String input)
解码 PunyCode为字符串
|
static String |
PunyCode.decodeDomain(String domain)
解码 PunyCode为域名
|
static String |
PunyCode.encode(CharSequence input)
将内容编码为PunyCode
|
static String |
PunyCode.encode(CharSequence input,
boolean withPrefix)
将内容编码为PunyCode
|
static String |
PunyCode.encodeDomain(String domain)
将域名编码为PunyCode,会忽略"."
|
Modifier and Type | Class and Description |
---|---|
class |
ComparatorException
比较异常
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
ZipUtil.gzip(byte[] buf)
Gzip压缩处理
|
static byte[] |
ZipUtil.gzip(File file)
Gzip压缩文件
|
static byte[] |
ZipUtil.gzip(InputStream in)
Gzip压缩文件
|
static byte[] |
ZipUtil.gzip(InputStream in,
int length)
Gzip压缩文件
|
static byte[] |
ZipUtil.gzip(String content,
Charset charset)
Gzip压缩处理
|
static byte[] |
ZipUtil.unGzip(byte[] buf)
Gzip解压处理
|
static String |
ZipUtil.unGzip(byte[] buf,
Charset charset)
Gzip解压缩处理
|
static byte[] |
ZipUtil.unGzip(InputStream in)
Gzip解压处理
|
static byte[] |
ZipUtil.unGzip(InputStream in,
int length)
Gzip解压处理
|
static File |
ZipUtil.unzip(File zipFile)
解压到文件名相同的目录中,使用UTF-8编码
|
static File |
ZipUtil.unzip(File zipFile,
Charset charset)
解压到文件名相同的目录中
|
static File |
ZipUtil.unzip(File zipFile,
File outFile)
解压,默认使用UTF-8编码
|
static File |
ZipUtil.unzip(InputStream in,
File outFile,
Charset charset)
解压
ZIP条目不使用高速缓冲。 |
static File |
ZipUtil.unzip(String zipFilePath)
解压到文件名相同的目录中,默认编码UTF-8
|
static File |
ZipUtil.unzip(String zipFilePath,
Charset charset)
解压到文件名相同的目录中
|
static File |
ZipUtil.unzip(String zipFilePath,
String outFileDir)
解压,默认UTF-8编码
|
static File |
ZipUtil.unzip(String zipFilePath,
String outFileDir,
Charset charset)
解压
|
static File |
ZipUtil.unzip(ZipInputStream zipStream,
File outFile)
解压
ZIP条目不使用高速缓冲。 |
static File |
ZipUtil.zip(File srcFile)
打包到当前目录,使用默认编码UTF-8
|
static File |
ZipUtil.zip(File zipFile,
boolean withSrcDir,
File... srcFiles)
对文件或文件目录进行压缩
使用默认UTF-8编码 |
static File |
ZipUtil.zip(File srcFile,
Charset charset)
打包到当前目录
|
static File |
ZipUtil.zip(File zipFile,
Charset charset,
boolean withSrcDir,
File... srcFiles)
对文件或文件目录进行压缩
|
static File |
ZipUtil.zip(File zipFile,
Charset charset,
Resource... resources)
对流中的数据加入到压缩文件
路径列表和流列表长度必须一致 |
static File |
ZipUtil.zip(File zipFile,
String[] paths,
InputStream[] ins)
对流中的数据加入到压缩文件
路径列表和流列表长度必须一致 |
static File |
ZipUtil.zip(File zipFile,
String[] paths,
InputStream[] ins,
Charset charset)
对流中的数据加入到压缩文件
路径列表和流列表长度必须一致 |
static File |
ZipUtil.zip(File zipFile,
String path,
InputStream in)
对流中的数据加入到压缩文件
使用默认编码UTF-8 |
static File |
ZipUtil.zip(File zipFile,
String path,
InputStream in,
Charset charset)
对流中的数据加入到压缩文件
|
static File |
ZipUtil.zip(File zipFile,
String path,
String data)
对流中的数据加入到压缩文件,使用默认UTF-8编码
|
static File |
ZipUtil.zip(File zipFile,
String path,
String data,
Charset charset)
对流中的数据加入到压缩文件
|
static File |
ZipUtil.zip(String srcPath)
打包到当前目录,使用默认编码UTF-8
|
static File |
ZipUtil.zip(String srcPath,
Charset charset)
打包到当前目录
|
static File |
ZipUtil.zip(String srcPath,
String zipPath)
对文件或文件目录进行压缩
不包含被打包目录 |
static File |
ZipUtil.zip(String srcPath,
String zipPath,
boolean withSrcDir)
对文件或文件目录进行压缩
|
static File |
ZipUtil.zip(String srcPath,
String zipPath,
Charset charset,
boolean withSrcDir)
对文件或文件目录进行压缩
|
Modifier and Type | Class and Description |
---|---|
class |
ConvertException
转换异常
|
Modifier and Type | Class and Description |
---|---|
class |
DateException
工具类异常
|
Modifier and Type | Class and Description |
---|---|
class |
CloneException
克隆异常
|
class |
DependencyException
依赖异常
|
class |
StatefulException
带有状态码的异常
|
class |
ValidateException
验证异常
|
Modifier and Type | Class and Description |
---|---|
class |
IORuntimeException
IO运行时异常,常用于对IOException的包装
|
Modifier and Type | Method and Description |
---|---|
static <T> T |
IoUtil.readObj(InputStream in,
Class<?>... acceptClasses)
从流中读取对象,即对象的反序列化,读取后不关闭流
注意!!!
|
Modifier and Type | Class and Description |
---|---|
class |
NoResourceException
资源文件或资源不存在异常
|
Modifier and Type | Method and Description |
---|---|
<T> T |
StreamReader.readObj(Class<?>... acceptClasses)
从流中读取对象,即对象的反序列化
注意!!!
|
Modifier and Type | Class and Description |
---|---|
class |
WatchException
监听异常
|
Modifier and Type | Class and Description |
---|---|
static class |
DirectedWeightGraph.NegativeRingException
负环异常
|
Modifier and Type | Method and Description |
---|---|
static String |
UrlEncoder.encodeAll(String url,
Charset charset)
编码URL
将需要转换的内容(ASCII码形式之外的内容),用十六进制表示法转换出来,并在之前加上%开头。 |
static URL |
UrlUtil.getURL(URL url,
String relativePath)
获取相对于给定URL的新的URL
来自:org.springframework.core.io.UrlResource#createRelativeURL |
static URI |
UrlUtil.toURI(String location)
转字符串为URI
|
static URI |
UrlUtil.toURI(String location,
boolean isEncode)
转字符串为URI
|
static URI |
UrlUtil.toURI(URL url)
转URL为URI
|
static URI |
UrlUtil.toURI(URL url,
boolean isEncode)
转URL为URI
|
static URL |
UrlUtil.url(URI uri)
|
Modifier and Type | Class and Description |
---|---|
class |
PoolException
对象池异常
|
Modifier and Type | Method and Description |
---|---|
static Class<?> |
ClassDescUtil.descToClass(String desc)
Class描述转Class
"[Z" => boolean[].class
"[[Ljava/util/Map;" => java.util.Map[][].class
|
static Class<?> |
ClassDescUtil.descToClass(String desc,
boolean isInitialized,
ClassLoader cl)
Class描述转Class
"[Z" => boolean[].class
"[[Ljava/util/Map;" => java.util.Map[][].class
|
static Object |
FieldUtil.getFieldValue(Object obj,
Field field)
获取字段值
|
static Object |
FieldUtil.getFieldValue(Object obj,
String fieldName)
获取字段值
|
static Object |
FieldUtil.getStaticFieldValue(Field field)
获取静态字段值
|
Object |
FieldInvoker.invokeGet(Object obj)
获取字段值
|
void |
FieldInvoker.invokeSet(Object obj,
Object value)
设置字段值,传入的字段值必须和字段类型一致,否则抛出异常
|
static <T> T |
ConstructorUtil.newInstance(Class<T> clazz,
Object... params)
实例化对象
|
static <T> T |
ConstructorUtil.newInstance(String clazz)
实例化对象
类必须有空构造函数 |
static void |
FieldUtil.setFieldValue(Object obj,
Field field,
Object value)
设置字段值,如果值类型必须与字段类型匹配,会自动转换对象类型
|
static void |
FieldUtil.setFieldValue(Object obj,
Field field,
Object value,
Converter converter)
设置字段值,如果值类型必须与字段类型匹配,会自动转换对象类型
|
static void |
FieldUtil.setFieldValue(Object obj,
String fieldName,
Object value)
设置字段值
|
static void |
FieldUtil.setStaticFieldValue(Field field,
Object value)
设置静态(static)字段值
|
Modifier and Type | Method and Description |
---|---|
static MethodHandle |
LookupUtil.unreflect(Member methodOrConstructor)
|
Modifier and Type | Method and Description |
---|---|
static <T> T |
MethodUtil.invoke(Object obj,
Method method,
Object... args)
执行方法
对于用户传入参数会做必要检查,包括:
1、忽略多余的参数
2、参数不够补齐默认值
3、传入参数为null,但是目标参数类型为原始类型,做转换
|
static <T> T |
MethodHandleUtil.invoke(Object obj,
Method method,
Object... args)
执行接口或对象中的方法
interface Duck { default String quack() { return "Quack"; } } Duck duck = (Duck) Proxy.newProxyInstance( ClassLoaderUtil.getClassLoader(), new Class[] { Duck.class }, MethodHandleUtil::invoke); |
<T> T |
MethodInvoker.invoke(Object target,
Object... args) |
static <T> T |
MethodUtil.invoke(Object obj,
String methodName,
Object... args)
执行对象中指定方法
如果需要传递的参数为null,请使用NullWrapperBean来传递,不然会丢失类型信息
|
static <T> T |
MethodHandleUtil.invokeExact(Object obj,
Method method,
Object... args)
执行接口或对象中的方法,参数类型不做转换,必须与方法参数类型完全匹配
interface Duck { default String quack() { return "Quack"; } } Duck duck = (Duck) Proxy.newProxyInstance( ClassLoaderUtil.getClassLoader(), new Class[] { Duck.class }, MethodHandleUtil::invoke); |
static <T> T |
MethodUtil.invokeStatic(Method method,
Object... args)
执行静态方法
|
<T> T |
MethodInvoker.invokeStatic(Object... args)
执行静态方法
|
static <T> T |
MethodUtil.invokeWithCheck(Object obj,
Method method,
Object... args)
执行方法
执行前要检查给定参数: 1. |
Modifier and Type | Class and Description |
---|---|
class |
SpiException
SPI异常
|
Modifier and Type | Class and Description |
---|---|
class |
ThreadException
线程异常
|
Modifier and Type | Method and Description |
---|---|
static int |
RuntimeUtil.getPid()
获取当前进程ID,首先获取进程名称,读取@前的ID值,如果不存在,则读取进程名的hash值
|
Modifier and Type | Method and Description |
---|---|
static Document |
XmlUtil.readXml(InputStream inputStream)
读取解析XML文件
编码在XML中定义 |
static Document |
XmlUtil.readXml(Reader reader)
读取解析XML文件
|
Modifier and Type | Class and Description |
---|---|
class |
CronException
定时任务异常
|
Modifier and Type | Class and Description |
---|---|
class |
CryptoException
加密异常
|
Modifier and Type | Class and Description |
---|---|
class |
DbException
数据库异常
|
Modifier and Type | Class and Description |
---|---|
class |
CompressException
压缩解压异常语言异常
|
Modifier and Type | Class and Description |
---|---|
class |
FtpException
Ftp异常
|
Modifier and Type | Class and Description |
---|---|
class |
MailException
邮件异常
|
Modifier and Type | Class and Description |
---|---|
class |
ManagementException
FtpException异常
|
Modifier and Type | Class and Description |
---|---|
class |
PinyinException
模板异常
|
Modifier and Type | Class and Description |
---|---|
class |
QrCodeException
Qrcode异常
|
Modifier and Type | Method and Description |
---|---|
static org.springframework.beans.factory.config.ConfigurableListableBeanFactory |
SpringUtil.getConfigurableBeanFactory()
获取
ConfigurableListableBeanFactory |
Modifier and Type | Class and Description |
---|---|
class |
SshException
SSH异常
|
Modifier and Type | Class and Description |
---|---|
class |
TemplateException
模板异常
|
Modifier and Type | Class and Description |
---|---|
class |
TokenizerException
分词异常
|
Modifier and Type | Class and Description |
---|---|
class |
HttpException
HTTP异常
|
Modifier and Type | Class and Description |
---|---|
class |
SoapRuntimeException
SOAP异常
|
Modifier and Type | Class and Description |
---|---|
class |
JSONException
JSON异常
|
Modifier and Type | Class and Description |
---|---|
class |
JWTException
JWT异常
|
Modifier and Type | Class and Description |
---|---|
class |
POIException
POI异常
|
Modifier and Type | Class and Description |
---|---|
class |
StopReadException
读取结束异常,用于标记读取结束
Sax方式读取时,如果用户在RowHandler中抛出此异常,表示读取结束,此时不再读取其他数据 |
Modifier and Type | Class and Description |
---|---|
class |
SettingException
设置异常
|
Modifier and Type | Class and Description |
---|---|
class |
SocketRuntimeException
Socket异常
|
Copyright © 2025. All rights reserved.