Hutool 39 New <SIMPLE>

Hutool 39 New: A Comprehensive Guide to the Latest Breakthroughs in Java Utility Heaven

Example 1: Bulk Image Resizing with Metadata Preservation

// Resize every PNG in a directory, keeping EXIF data
File[] images = FileUtil.ls("/photos");
for (File img : images) 
    ImgUtil.scale(img, FileUtil.file("/thumbnails", img.getName()), 0.5f);
    // New in v39: Preserves orientation using ImageMetadataReader

3.4 core Enhancements

4. Migration from 5.x to 6.x

3.6 Extra Utilities

The One Breaking Change (Sorry!)

StrUtil.subBetween() now returns null (instead of empty string) when the delimiters aren’t found. This aligns with “absent” semantics. A quick grep of your codebase will catch any affected calls.

Example 3: Scheduled Report Generator Using CronUtil

// Run every Monday at 9 AM with virtual thread executor
CronUtil.schedule("0 0 9 ? * MON", "reportJob", () -> 
    try (var exec = ThreadUtil.newVirtualExecutor()) 
        exec.submit(() -> generateDailyReport());
);
CronUtil.setMatchSecond(true);
CronUtil.start();