A comprehensive Java utility library providing static method wrappers for common operations to reduce API learning costs and improve development efficiency
npx @tessl/cli install tessl/maven-cn-hutool--hutool-all@5.8.00
# Hutool
1
2
Hutool is a comprehensive Java utility library that provides static method wrappers to reduce Java API learning costs and improve development efficiency. It combines 19 specialized modules covering everything from basic string manipulation to advanced encryption, HTTP clients, and AI model integration.
3
4
## Package Information
5
6
- **Package Name**: hutool-all
7
- **Package Type**: maven
8
- **Group ID**: cn.hutool
9
- **Language**: Java
10
- **Minimum Java Version**: 8+
11
- **Installation**:
12
```xml
13
<dependency>
14
<groupId>cn.hutool</groupId>
15
<artifactId>hutool-all</artifactId>
16
<version>5.8.40</version>
17
</dependency>
18
```
19
20
## Core Imports
21
22
```java
23
// Core utilities - most commonly used
24
import cn.hutool.core.util.*;
25
26
// Specific utilities
27
import cn.hutool.core.util.StrUtil;
28
import cn.hutool.core.util.DateUtil;
29
import cn.hutool.core.util.RandomUtil;
30
import cn.hutool.core.bean.BeanUtil;
31
import cn.hutool.core.collection.CollUtil;
32
import cn.hutool.core.convert.Convert;
33
import cn.hutool.core.io.FileUtil;
34
import cn.hutool.core.io.IoUtil;
35
36
// Specialized modules
37
import cn.hutool.http.HttpUtil;
38
import cn.hutool.json.JSONUtil;
39
import cn.hutool.crypto.SecureUtil;
40
import cn.hutool.db.DbUtil;
41
import cn.hutool.log.StaticLog;
42
```
43
44
## Basic Usage
45
46
```java
47
import cn.hutool.core.util.*;
48
import cn.hutool.http.HttpUtil;
49
import cn.hutool.json.JSONUtil;
50
51
// String operations
52
String result = StrUtil.format("Hello {}, welcome to {}", "World", "Hutool");
53
boolean isEmpty = StrUtil.isBlank(" ");
54
55
// Date operations
56
String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
57
Date parsed = DateUtil.parse("2023-01-01", "yyyy-MM-dd");
58
59
// HTTP requests
60
String response = HttpUtil.get("https://api.example.com/data");
61
String jsonPost = HttpUtil.post("https://api.example.com/submit", "{\"key\":\"value\"}");
62
63
// JSON processing
64
JSONObject json = JSONUtil.createObj()
65
.put("name", "hutool")
66
.put("version", "5.8.40");
67
String jsonStr = json.toString();
68
69
// File operations
70
String content = FileUtil.readUtf8String("config.txt");
71
FileUtil.writeUtf8String("output.txt", "Hello Hutool");
72
73
// Random data generation
74
String randomStr = RandomUtil.randomString(10);
75
int randomInt = RandomUtil.randomInt(1, 100);
76
```
77
78
## Architecture
79
80
Hutool follows a modular architecture with 19 specialized modules:
81
82
- **hutool-core**: Foundation utilities (beans, collections, dates, IO, reflection)
83
- **hutool-http**: HTTP client and server utilities
84
- **hutool-json**: JSON parsing and generation
85
- **hutool-crypto**: Encryption, decryption, and hashing
86
- **hutool-db**: Database access and ORM utilities
87
- **hutool-extra**: Third-party integrations (templates, email, QR codes)
88
- **15 additional specialized modules** for specific use cases
89
90
All utilities follow consistent patterns:
91
- Static utility methods with "Util" suffix
92
- Null-safe operations
93
- Method overloading for different parameter combinations
94
- Builder patterns for complex configurations
95
- Factory patterns for object creation
96
97
## Capabilities
98
99
### Core String Operations
100
101
Comprehensive string manipulation including validation, formatting, parsing, and transformation.
102
103
```java { .api }
104
// Validation methods
105
public static boolean isBlank(CharSequence str);
106
public static boolean isEmpty(CharSequence str);
107
public static boolean isNotBlank(CharSequence str);
108
109
// Formatting and manipulation
110
public static String format(String template, Object... params);
111
public static String join(CharSequence delimiter, Object... elements);
112
public static String[] split(CharSequence str, CharSequence separator);
113
```
114
115
[Core String Operations](./core-string-operations.md)
116
117
### Date and Time Handling
118
119
Date parsing, formatting, calculation, and manipulation utilities.
120
121
```java { .api }
122
// Parsing and formatting
123
public static Date parse(CharSequence dateStr, String format);
124
public static String format(Date date, String format);
125
126
// Date calculations
127
public static Date offset(Date date, DateField dateField, int offset);
128
public static long between(Date beginDate, Date endDate, DateUnit unit);
129
```
130
131
[Date and Time Handling](./date-time-handling.md)
132
133
### HTTP Client Operations
134
135
HTTP request/response handling with support for various content types and authentication.
136
137
```java { .api }
138
// Simple HTTP methods
139
public static String get(String urlString);
140
public static String post(String urlString, String body);
141
public static HttpResponse execute(HttpRequest request);
142
143
// File operations
144
public static long downloadFile(String url, File targetFile);
145
```
146
147
[HTTP Client Operations](./http-client-operations.md)
148
149
### JSON Processing
150
151
JSON parsing, generation, and manipulation with path-based access.
152
153
```java { .api }
154
// JSON creation and parsing
155
public static JSONObject createObj();
156
public static JSONArray createArray();
157
public static JSONObject parseObj(String jsonStr);
158
public static JSONArray parseArray(String jsonStr);
159
```
160
161
[JSON Processing](./json-processing.md)
162
163
### Bean and Object Manipulation
164
165
Bean property access, copying, conversion, and dynamic manipulation.
166
167
```java { .api }
168
// Bean operations
169
public static void copyProperties(Object source, Object target);
170
public static <T> T toBean(Object source, Class<T> targetType);
171
public static Map<String, Object> beanToMap(Object bean);
172
```
173
174
[Bean and Object Manipulation](./bean-object-manipulation.md)
175
176
### Collection Utilities
177
178
Collection creation, manipulation, filtering, and transformation utilities.
179
180
```java { .api }
181
// Collection operations
182
public static <T> List<T> newArrayList(T... values);
183
public static boolean isEmpty(Collection<?> collection);
184
public static <T> List<T> filter(Collection<T> collection, Predicate<T> predicate);
185
```
186
187
[Collection Utilities](./collection-utilities.md)
188
189
### File and IO Operations
190
191
File reading, writing, copying, and stream manipulation utilities.
192
193
```java { .api }
194
// File operations
195
public static String readUtf8String(File file);
196
public static void writeUtf8String(String content, File file);
197
public static void copy(File src, File dest);
198
199
// Stream operations
200
public static String read(InputStream in, Charset charset);
201
public static void copy(InputStream in, OutputStream out);
202
```
203
204
[File and IO Operations](./file-io-operations.md)
205
206
### Cryptographic Operations
207
208
Encryption, decryption, hashing, and digital signature utilities.
209
210
```java { .api }
211
// Hash operations
212
public static String md5(String data);
213
public static String sha256(String data);
214
215
// Symmetric encryption
216
public static SymmetricCrypto aes(byte[] key);
217
public static SymmetricCrypto des(byte[] key);
218
```
219
220
[Cryptographic Operations](./cryptographic-operations.md)
221
222
### Database Access
223
224
JDBC wrapper with ActiveRecord pattern and connection management.
225
226
```java { .api }
227
// Database operations
228
public static List<Entity> findAll(String tableName);
229
public static Entity findById(String tableName, Object id);
230
public static int insert(String tableName, Entity entity);
231
```
232
233
[Database Access](./database-access.md)
234
235
### Additional Utilities
236
237
Specialized utilities for validation, random generation, reflection, and system operations.
238
239
```java { .api }
240
// Validation
241
public static boolean isEmail(CharSequence email);
242
public static boolean isPhone(CharSequence mobile);
243
244
// Random generation
245
public static String randomString(int length);
246
public static int randomInt(int min, int max);
247
248
// Reflection
249
public static <T> T newInstance(Class<T> clazz, Object... params);
250
public static Object invoke(Object obj, String methodName, Object... args);
251
```
252
253
[Additional Utilities](./additional-utilities.md)
254
255
## Types
256
257
### Common Enums and Constants
258
259
```java { .api }
260
// Date field enumeration
261
public enum DateField {
262
YEAR, MONTH, DAY_OF_MONTH, HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND
263
}
264
265
// Date unit enumeration
266
public enum DateUnit {
267
MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR
268
}
269
270
// HTTP method enumeration
271
public enum Method {
272
GET, POST, PUT, DELETE, HEAD, OPTIONS, PATCH, TRACE
273
}
274
275
// Character encoding constants
276
public interface CharsetUtil {
277
Charset UTF_8 = StandardCharsets.UTF_8;
278
Charset GBK = Charset.forName("GBK");
279
String UTF_8_NAME = "UTF-8";
280
}
281
```
282
283
### Core Data Structures
284
285
```java { .api }
286
// Enhanced Date class
287
public class DateTime extends Date {
288
public DateTime();
289
public DateTime(Date date);
290
public DateTime(String dateStr, String format);
291
292
public DateTime offset(DateField field, int offset);
293
public String toString(String format);
294
public boolean isWeekend();
295
}
296
297
// Dictionary implementation
298
public class Dict extends LinkedHashMap<String, Object> {
299
public static Dict create();
300
public Dict set(String key, Object value);
301
public <T> T get(String key, Class<T> type);
302
}
303
304
// Database entity
305
public class Entity extends LinkedHashMap<String, Object> {
306
public static Entity create();
307
public Entity set(String key, Object value);
308
public <T> T get(String key, Class<T> type);
309
}
310
```