: Covers everything from JSON parsing and XML handling to Cron job scheduling and HTTP clients. code example for one of these modules, or are you looking for a summary of changes compared to a later version like 5.x? openai-sdk-java/pom.xml at master - GitHub
@FunctionalInterface public interface FileHandler void onChange(Path path, WatchEvent.Kind<?> event);
| Area | Limitation | |------|-------------| | | JDK 11+ works but not optimized for modules. | | Performance | JSON parser slower than Jackson. | | Async HTTP | No built-in async client (added in 5.x). | | Tree structure | TreeUtil exists but less powerful than 5.x. | Hutool 3.9
Reading files into lines, lists, or strings with a single method call.
String[] splitText = StrUtil.split(text, ","); System.out.println("Split text: " + splitText); : Covers everything from JSON parsing and XML
: Includes safe methods to copy, move, delete, and read files. It abstracts away the stream lifecycle entirely.
Exploring Hutool 3.9: A Deep Dive into the Legacy Java Utility Library | | Performance | JSON parser slower than Jackson
| Module Name | Official Description | Technical Role in the Project | | :--- | :--- | :--- | | | Core, including Bean operations, dates, and various Utilities. | This is the heart of the library . It contains the foundational tools like StrUtil , DateUtil , CollUtil , FileUtil , Convert , ObjectUtil , and ReflectUtil used across every other module. | | hutool-log | A log facade that automatically identifies the logging implementation. | Provides a unified logging interface that auto-detects and delegates to frameworks like SLF4J, Log4j, or Logback, simplifying logging setup in your application. | | hutool-setting | A more powerful encapsulation of Setting configuration files and Properties. | Extends standard .properties files with support for a more robust Setting format, allowing for grouped configurations, variable substitution, and auto-reload, which is more powerful than java.util.Properties . | | hutool-crypto | Encryption and decryption module, providing symmetric, asymmetric, and digest algorithm encapsulation. | This is your go-to for security . It wraps JDK's JCA (Java Cryptography Architecture) to provide easy-to-use APIs for encryption (AES, DES), hashing (MD5, SHA), and digital signatures (RSA, DSA). | | hutool-http | An HTTP client encapsulation based on HttpUrlConnection . | Provides simple and convenient methods ( HttpUtil.get() , HttpUtil.post() ) for making HTTP requests, handling redirections, and processing responses without requiring external HTTP client libraries. | | hutool-db | JDBC-encapsulated data operations, based on the ActiveRecord design pattern. | A lightweight ORM (Object-Relational Mapping) tool that simplifies database operations. It allows you to execute SQL and map results to JavaBeans without the complexity of full-fledged ORM frameworks like Hibernate. | | hutool-aop | JDK dynamic proxy encapsulation, providing aspect support outside of IOC containers. | Enables simple Aspect-Oriented Programming (AOP) without Spring. It allows you to create proxy objects and intercept method calls, useful for tasks like logging, transaction management, or performance monitoring. | | hutool-cache | Simple cache implementation. | Offers a straightforward Cache interface with implementations like FIFOCache and LRUCache , perfect for local, lightweight in-memory caching needs. | | hutool-cron | Scheduled task module, providing a Crontab-like expression-based scheduler. | A lightweight, built-in cron expression scheduler. It allows you to define and run periodic tasks (e.g., CronUtil.schedule("*/5 * * * * *", () -> System.out.println("Task executed")) ) without relying on external schedulers like Quartz. | | hutool-captcha | Image captcha generation. | Generates simple CAPTCHA images programmatically, which can be used to prevent automated form submissions in web applications. | | hutool-dfa | Multi-keyword lookup based on the DFA model. | Implements a Deterministic Finite Automaton for high-performance filtering of sensitive words or keywords in a text, which is crucial for content moderation systems. | | hutool-extra | Extension module, encapsulating third-party libraries (template engines, mail, servlet, QR code, emoji, FTP, tokenizer, etc.). | This is the integration hub . It provides optional wrappers for popular third-party libraries like template engines (Freemarker, Velocity), mail sending, QR code generation, and various other utilities. Dependencies are optional. | | hutool-json | JSON implementation. | A built-in, lightweight JSON parser and formatter, offering an alternative to libraries like Jackson or Gson when you need simple JSON operations without extra dependencies. | | hutool-bloomFilter | Bloom filter, providing a Bloom filter with some hash algorithms. | Provides a probabilistic data structure for efficiently testing whether an element is a member of a set. It's useful in cases where you need to avoid unnecessary operations on non-existent items, such as in a database read-through scenario. | | hutool-poi | Encapsulation of Excel and Word using POI. | This module simplifies working with Microsoft Office documents via Apache POI, making it easy to read and write Excel files with fewer lines of code. | | hutool-socket | Socket encapsulation based on Java's NIO and AIO. | Provides a simplified API for socket programming, including a server and client implementation, which can be used for building custom network communication protocols. | | hutool-system | System parameter invocation encapsulation (e.g., JVM information). | Allows easy access to system-level information, such as JVM spec, runtime details, and OS information, which is helpful for debugging and system monitoring. |
KeyGenerator keyGen = KeyGenerator.getInstance("AES"); keyGen.init(128); SecretKey secretKey = keyGen.generateKey(); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, secretKey); byte[] encryptedBytes = cipher.doFinal("Hello World".getBytes("UTF-8")); String encryptedHex = DatatypeConverter.printHexBinary(encryptedBytes); Use code with caution.
Methods handle null safely, preventing NullPointerException .