Hutool Pro 30 Hot Download Page
// A complete file backup service with logging, crypto, and scheduling
public class BackupService {
private static final Logger log = LogFactory.get();
public void backupAndEncrypt(String sourcePath, String destPath) {
File source = FileUtil.file(sourcePath);
File dest = FileUtil.file(destPath);
// Copy file
FileUtil.copy(source, dest, true);
log.info("Copied {} to {}", sourcePath, destPath);
// Encrypt backup
Aes aes = SecureUtil.aes("my-secret-key-16bytes".getBytes());
String content = FileUtil.readUtf8String(dest);
String encrypted = aes.encryptBase64(content);
FileUtil.writeUtf8String(encrypted, dest);
// Verify
log.info("Backup encrypted and saved at {}", destPath);
}
}
Cache<String, String> cache = CacheUtil.newLRUCache(100);
cache.put("key", "value", DateUnit.SECOND.getMillis() * 10); // TTL 10s
String val = cache.get("key");
// Never write null checks again
if (StrUtil.isBlank(input)) ...
String masked = StrUtil.hide("13812345678", 3, 7); // 138****5678
String[] split = StrUtil.splitToArray("a,b,c", ','); // [a,b,c]