博主
258
258
258
258
专辑

第三节 使用HuTool工具实现对字符串的处理

亮子 2023-11-25 14:41:30 6335 0 0 0
 @ApiOperation("StrUtil使用:字符串工具")
    @GetMapping("/strUtil")
    public CommonResult strUtil(){
        //判断是否为空字符串?(null或者’‘都认定为空字符串)
        String str = null;
        StrUtil.isNotBlank(str);
        StrUtil.isBlank(str);
        //去除字符串的前后缀
        StrUtil.removeSuffix("a.jpg",".jpg");
        StrUtil.removePrefix("a.jpg","a.") ;
        //格式化字符串
        String template = "这只是一个占位符:{}";
        String str2 = StrUtil.format(template,"我是占位符");
        LOGGER.info("/strUtil format:{}",str2);
        return CommonResult.success(null,"操作成功!");
    }