A lightweight collection of common Java utility classes for everyday development tasks.
| Class | Description |
|---|---|
StringUtils |
String manipulation: isEmpty, capitalize, truncate, repeat, join, etc. |
DateUtils |
Date formatting, parsing, weekend detection, month boundaries |
CollectionUtils |
Null-safe collection checks, partition, firstOrNull |
JsonUtils |
JSON string escaping and simple map serialization |
FileUtils |
File read/write, extension parsing, existence checks |
MathUtils |
Clamp, round, factorial, GCD, even/odd checks |
NumberUtils |
Safe number parsing with default values |
ArrayUtils |
Array isEmpty, contains, reverse, indexOf |
Preconditions |
Argument validation (checkNotNull, checkArgument) |
MapBuilder |
Fluent API for building Map instances |
- Java 11+
- Maven 3.6+
import com.huweiming.utils.*;
// String operations
StringUtils.isBlank(" "); // true
StringUtils.capitalize("hello"); // "Hello"
StringUtils.truncateWithEllipsis("long text here", 10); // "long te..."
// Safe number parsing
NumberUtils.toInt("42", 0); // 42
NumberUtils.toInt("bad", 0); // 0
// Collection helpers
CollectionUtils.isEmpty(null); // true
CollectionUtils.partition(list, 3); // split into chunks of 3
// Map building
Map<String, Object> config = MapBuilder.<String, Object>hashMap()
.put("host", "localhost")
.put("port", 8080)
.build();mvn clean installmvn testMIT License