or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

tessl/maven-cn-hutool--hutool-core

Comprehensive Java utility library providing collections, strings, beans, dates, I/O, and numerous other utility functions.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/cn.hutool/hutool-core@5.8.x

To install, run

npx @tessl/cli install tessl/maven-cn-hutool--hutool-core@5.8.0

0

# Hutool Core

1

2

Hutool Core is a comprehensive Java utility library providing extensive functionality for collections, strings, beans, dates, I/O operations, and numerous other common programming tasks. It offers over 90 utility classes with thousands of static methods designed to simplify Java development with null-safe operations, type conversions, and practical helper functions.

3

4

## Package Information

5

6

- **Package Name**: cn.hutool:hutool-core

7

- **Package Type**: maven

8

- **Language**: Java

9

- **Installation**: Add to Maven `pom.xml`:

10

```xml

11

<dependency>

12

<groupId>cn.hutool</groupId>

13

<artifactId>hutool-core</artifactId>

14

<version>5.8.40</version>

15

</dependency>

16

```

17

18

## Core Imports

19

20

```java

21

import cn.hutool.core.util.StrUtil;

22

import cn.hutool.core.collection.CollUtil;

23

import cn.hutool.core.date.DateUtil;

24

import cn.hutool.core.io.FileUtil;

25

import cn.hutool.core.bean.BeanUtil;

26

import cn.hutool.core.convert.Convert;

27

```

28

29

## Basic Usage

30

31

```java

32

import cn.hutool.core.util.StrUtil;

33

import cn.hutool.core.collection.CollUtil;

34

import cn.hutool.core.date.DateUtil;

35

36

// String utilities

37

boolean isEmpty = StrUtil.isBlank(" "); // true

38

String formatted = StrUtil.format("Hello {}", "World"); // "Hello World"

39

40

// Collection utilities

41

List<String> list = CollUtil.newArrayList("a", "b", "c");

42

boolean hasItems = CollUtil.isNotEmpty(list); // true

43

44

// Date utilities

45

String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");

46

Date parsed = DateUtil.parse("2023-01-15", "yyyy-MM-dd");

47

```

48

49

## Architecture

50

51

Hutool Core is organized into distinct functional packages:

52

53

- **Static Utility Pattern**: All functionality exposed through static methods in *Util classes

54

- **Null-Safe Operations**: Extensive null checking throughout all utilities

55

- **Type Safety**: Generic type support where applicable with safe casting utilities

56

- **Builder Support**: Builder classes for complex object construction (StrBuilder, etc.)

57

- **Converter System**: Unified type conversion framework with extensible converters

58

- **Multi-Language Support**: Special utilities for Chinese-specific functionality (ID cards, phone numbers)

59

60

## Capabilities

61

62

### String Operations

63

64

Comprehensive string manipulation, formatting, conversion, and validation utilities.

65

66

```java { .api }

67

public class StrUtil {

68

public static boolean isBlank(CharSequence str);

69

public static boolean isEmpty(CharSequence str);

70

public static String format(String template, Object... params);

71

public static String utf8Str(Object obj);

72

}

73

```

74

75

[String Operations](./string-operations.md)

76

77

### Collection Operations

78

79

Utilities for creating, manipulating, and transforming Java collections with null-safe operations.

80

81

```java { .api }

82

public class CollUtil {

83

public static <T> boolean isEmpty(Collection<T> collection);

84

public static <T> boolean isNotEmpty(Collection<T> collection);

85

public static <T> List<T> newArrayList(T... values);

86

public static <T> Collection<T> union(Collection<T> coll1, Collection<T> coll2);

87

}

88

```

89

90

[Collection Operations](./collection-operations.md)

91

92

### Date and Time

93

94

Date parsing, formatting, manipulation, and calendar operations with support for both legacy Date API and Java 8+ time API.

95

96

```java { .api }

97

public class DateUtil {

98

public static String format(Date date, String format);

99

public static Date parse(String dateStr, String format);

100

public static long between(Date beginDate, Date endDate, DateUnit unit);

101

}

102

```

103

104

[Date and Time Operations](./date-time-operations.md)

105

106

### Type Conversion

107

108

Universal type conversion system supporting conversion between all common Java types.

109

110

```java { .api }

111

public class Convert {

112

public static <T> T convert(Class<T> type, Object value);

113

public static String toStr(Object value);

114

public static Integer toInt(Object value);

115

public static Boolean toBool(Object value);

116

}

117

```

118

119

[Type Conversion](./type-conversion.md)

120

121

### File and I/O Operations

122

123

File operations, stream handling, resource management, and NIO utilities.

124

125

```java { .api }

126

public class FileUtil {

127

public static String readUtf8String(File file);

128

public static void writeUtf8String(String content, File file);

129

public static boolean exist(String path);

130

public static File copy(File src, File dest, boolean isOverride);

131

}

132

133

public class IoUtil {

134

public static long copy(InputStream in, OutputStream out);

135

public static void close(Closeable closeable);

136

public static String read(InputStream in, Charset charset);

137

}

138

```

139

140

[File and I/O Operations](./file-io-operations.md)

141

142

### Random Operations

143

144

Random number generation, string generation, and collection element selection utilities.

145

146

```java { .api }

147

public class RandomUtil {

148

public static boolean randomBoolean();

149

public static int randomInt(int minInclude, int maxExclude);

150

public static String randomString(int length);

151

public static <T> T randomEle(List<T> list);

152

}

153

```

154

155

[Random Operations](./random-operations.md)

156

157

### XML Processing

158

159

XML parsing, manipulation, and serialization utilities.

160

161

```java { .api }

162

public class XmlUtil {

163

public static Document readXML(String pathOrContent);

164

public static String toStr(Node doc, boolean isPretty);

165

public static Element getElementByXPath(Document doc, String expression);

166

public static String escape(String string);

167

}

168

```

169

170

[XML Operations](./xml-operations.md)

171

172

### Compression Utilities

173

174

ZIP file compression, decompression, and archive manipulation utilities.

175

176

```java { .api }

177

public class ZipUtil {

178

public static File zip(String srcPath, String zipPath);

179

public static File unzip(String zipFilePath, String outFileDir);

180

public static byte[] gzip(String content, String charset);

181

public static String unGzip(byte[] buf, String charset);

182

}

183

```

184

185

[Compression Operations](./compression-operations.md)

186

187

### URL Processing

188

189

URL creation, parsing, encoding, and manipulation utilities.

190

191

```java { .api }

192

public class URLUtil {

193

public static URL url(String url);

194

public static String decode(String url);

195

public static String normalize(String url);

196

public static InputStream getStream(URL url);

197

}

198

```

199

200

[URL Operations](./url-operations.md)

201

202

### Object Operations

203

204

Object comparison, validation, cloning, and manipulation utilities.

205

206

```java { .api }

207

public class ObjectUtil {

208

public static boolean equals(Object obj1, Object obj2);

209

public static boolean isEmpty(Object obj);

210

public static <T> T defaultIfNull(T object, T defaultValue);

211

public static <T> T clone(T obj);

212

}

213

```

214

215

[Object Operations](./object-operations.md)

216

217

### Additional Utilities

218

219

Other specialized utility classes available in Hutool Core:

220

221

- **BeanUtil**: JavaBean manipulation, property copying, and object introspection

222

- **ArrayUtil**: Array creation, manipulation, and conversion utilities with null-safe operations

223

- **NumberUtil**: Number parsing, formatting, mathematical operations, and validation utilities

224

- **ReflectUtil**: Reflection utilities for class introspection, method invocation, and field access

225

- **ReUtil**: Regular expression utilities for pattern matching, replacement, and extraction

226

- **NetUtil**: Network utilities for IP address handling, URL operations, and network connectivity

227

- **ImgUtil**: Image processing utilities for reading, writing, scaling, and format conversion

228

- **HashUtil/HexUtil**: Hash generation, encoding/decoding, and basic cryptographic utilities

229

- **IdcardUtil/PhoneUtil**: Specialized utilities for Chinese development (ID cards, phone numbers)

230

231

## Common Types

232

233

```java { .api }

234

// Date unit enumeration

235

public enum DateUnit {

236

MS, SECOND, MINUTE, HOUR, DAY, WEEK

237

}

238

239

// Charset utilities

240

public class CharsetUtil {

241

public static final Charset UTF_8 = StandardCharsets.UTF_8;

242

public static final Charset GBK = Charset.forName("GBK");

243

}

244

245

// String pool constants

246

public interface StrPool {

247

String EMPTY = "";

248

String NULL = "null";

249

String SPACE = " ";

250

String TAB = "\t";

251

String DOT = ".";

252

String SLASH = "/";

253

String BACKSLASH = "\\";

254

}

255

```