1、在项目中引入hutool的jar包
2、首先定义出一个String类型的字符串
3、int length = StrUtil.length(str);//获取字符串的长度
4、执行程序查看结果
5、如果字符串是null则返回0