Hutool Java Utility Library
repository·v5-master·Indexed 12 days ago
https://github.com/chinabugotech/hutoolA comprehensive Java utility library providing practical classes for common development tasks. It includes modules for core utilities (collections, IO, threading, Bean manipulation), encryption (hutool-crypto), HTTP clients (hutool-http), JSON (hutool-json), JDBC wrappers (hutool-db), JWT (hutool-jwt), AI model integration (hutool-ai), and Apache POI wrappers for Excel and Word (hutool-poi). Version 5.x requires JDK 8 or higher.
What's inside Hutool
- Hutool-core is the foundational module of the Hutool project. It provides a comprehensive set of basic utility classes designed to simplify common Java development tasks. Key areas of coverage include collections, Maps, IO, threading, Bean manipulation, image processing, and concurrency utilities.
Overview of Hutool components
v5-masterHutool is a comprehensive Java utility library. You can either include all modules using
hutool-allor import specific modules individually to keep your project lightweight.Key modules include:
Module Description hutool-coreCore utilities including Bean operations, Date, and various Utils hutool-cryptoEncryption/Decryption (Symmetric, Asymmetric, and Digest algorithms) hutool-httpHTTP client based on HttpUrlConnectionhutool-jsonJSON implementation hutool-dbJDBC wrapper based on ActiveRecord principles hutool-extraExtensions for Template Engines, Mail, Servlet, QR Codes, FTP, etc. hutool-jwtJSON Web Token (JWT) implementation hutool-aiAI Large Model wrappers hutool-cacheSimple cache implementation hutool-cronScheduled tasks using Crontab expressions hutool-captchaImage captcha implementation hutool-poiWrappers for Apache POI (Excel and Word) hutool-bloomFilterBloom Filter implementation hutool-dfaMulti-keyword searching based on DFA model hutool-aopJDK Dynamic Proxy for AOP support without IOC hutool-logLog facade that automatically identifies logging implementations hutool-socketSocket wrappers based on Java NIO and AIO hutool-systemSystem parameter wrappers (e.g., JVM info) hutool-scriptScript execution wrappers (e.g., Javascript) hutool-settingEnhanced Setting and Properties configuration hutool-lock(Implicitly part of core/concurrency) Overview of Hutool Modules
v5-masterHutool is a comprehensive library of Java tools encapsulated through static methods. You can either include all modules via
hutool-allor import specific modules individually to keep your project lightweight.Key modules include:
hutool-core: Core operations (Beans, dates, etc.)hutool-crypto: Symmetric, asymmetric, and digest algorithmshutool-http: HTTP clienthutool-json: JSON processinghutool-extra: Third-party wrappers (Mail, QR code, Template engines, etc.)hutool-poi: Excel and Word tools via Apache POIhutool-captcha: Image Captcha generationhutool-jwt: JSON Web Token implementationhutool-db: Database operations using ActiveRecord patternshutool-cache: Simple caching mechanismshutool-cron: Task scheduling with Cron expressions
Use the JWT module for token management
v5-masterStarting from version 5.7.0, Hutool includes a dedicated JWT (JSON Web Token) module. It provides capabilities for creating, parsing, and validating JWTs. The module includes
JWTValidatorandRegisteredPayloadclasses. Note that in version 5.7.3, the default JWT behavior was changed to be ordered, and the payload date format was standardized to seconds.// Available since 5.7.0 // Includes JWT creation, parsing, and validationUse the universal converter for type conversion
v5-masterTheconvertmodule provides a "universal" converter system. It uses theConverterinterface and aConverterRegistryto handle arbitrary data type conversions. You can also register custom converters to extend the system's capabilities.Use Bean properties with @Alias annotation
v5-masterIn version 5.2.0, Hutool added support for the
@Aliasannotation on Bean fields. This annotation is respected during various operations, including converting Beans to Maps and vice versa, and when usingReflectUtil.getFieldValue.public class User { @Alias("user_name") private String name; } // ReflectUtil and Bean conversion tools will now recognize "user_name" as the field key.Hutool-core available utility modules
v5-masterHutool-core is organized into several functional modules. Depending on your requirements, you can use specific utilities for:
- Data & Transformation:
bean(Bean manipulation),convert(Universal type conversion),codec(BaseN, BCD, PunyCode, etc.),text(String manipulation, CSV),math(Permutations, combinations). - Collections & Maps:
collection(Iterators and collection wrappers),map(Table implementations, WeakMap),stream(Stream API wrappers). - IO & Files:
io(Stream copying, Checksum, File watching),compress(Zip, Gzip, Zlib). - Concurrency & Threading:
thread(Locks, CompletableFuture, Thread pools),lang(Design patterns like Singleton). - System & Environment:
net(IP, SSL, URL),swing(Desktop/AWT automation),compiler(Dynamic Java compilation). - Specialized Utilities:
date(Date/Time parsing/formatting),img(Image/GIF processing),exceptions(Exception handling),util(Regex, XML, Reflection, Random, etc.).
- Data & Transformation:
Install Hutool via Maven
v5-masterTo include the full suite of Hutool tools in your Java project using Maven, add the
hutool-alldependency to yourpom.xmlfile.Note: Hutool 5.x requires JDK 8 or higher. If you are using JDK 7, you must use Hutool 4.x (which is no longer updated).
```xml <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.8.47</version> </dependency> ```埋Migrate to JDK 8+ for Hutool 5.0.0
v5-masterWith the release of version 5.0.0, the minimum required JDK was upgraded to Java 8. This version also introduced comprehensive support for thejava.timepackage acrossDateUtil,DateTime, andConvert.Migrate POI dependency for version 5.6.0+
v5-masterImportant: From version 5.6.0 onwards, Hutool no longer supports Apache POI 3.x and has added compatibility for POI 5.x. If your project relies on POI 3.x, you must upgrade to POI 5.x to maintain compatibility with Hutool's POI components.Download Hutool JAR files manually
v5-masterIf you are not using a dependency management tool like Maven or Gradle, you can download the
hutool-all-X.X.X.jardirectly from Maven Central.Note: Hutool 5.x requires JDK 8 or higher. If you are using JDK 7, you must use Hutool 4.x (which is no longer updated).
https://repo1.maven.org/maven2/cn/hutool/hutool-all/5.8.47/Install Hutool via Gradle
v5-masterTo include the full suite of Hutool tools in your Java project using Gradle, add the following line to your dependencies block:
Note: Hutool 5.x requires JDK 8 or higher. If you are using JDK 7, you must use Hutool 4.x (which is no longer updated).
implementation 'cn.hutool:hutool-all:5.8.47'