0
点赞
收藏
分享

微信扫一扫

java 判断byte(数据库blob)的编码格式

1、首先添加依赖

<dependency>
            <groupId>com.googlecode.juniversalchardet</groupId>
            <artifactId>juniversalchardet</artifactId>
            <version>1.0.3</version>
        </dependency>
2、案例操作
List<Dto> dto = Mapper.get1("1643424790527_3F200045");
            for (Dto to : dto) {
                byte[] jsondata = to .getJsondata();//实体属性为byte[],对应的是数据库字段类型blob

                UniversalDetector detector = new UniversalDetector(null);
                detector.handleData(jsondata, 0, jsondata.length);
                detector.dataEnd();
                String encoding = detector.getDetectedCharset();
                detector.reset();

                System.out.println(encoding);//得到数据编码格式
            }
举报

相关推荐

0 条评论