将字符串转换为字节然后转换为int [英] Transform String to byte then to int

查看:66
本文介绍了将字符串转换为字节然后转换为int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了很多与此主题有关的问题,但无法解决我的问题.

I found lots of questions about this topic but i was not able to solve my issue.

用户将输入一个名称 String ,我需要将其转换为 List< int> ,以将其保存在代表名称中每个字符的数据库中.

User will put a name String and I need to transform it to a List<int> to save it in database representing each character of the name.

它可以与拉丁绞接系统配合使用,但是需要与其他书写系统(如阿拉伯或西里尔字母)配合使用.

It is working with latin wring system but this need to be working with other writing system such as arabic or cyrillic script.

List<Integer> intName = new ArrayList<>();
String splitName = currentName.split("");

for (final String currentString : splitConferenceName) {
    final byte[] temp = currentString.getBytes(StandardCharsets.UTF_8);
    final Byte b = temp[0];
    intName.add(b.intValue());
}

我也尝试使用ByteBuffer,但是得到了Bufferunderflowexception.

I also try to use ByteBuffer but got Bufferunderflowexception.

要检查操作员是否良好,我使用此网站: https://onlinestringtools.com/convert-decimal-to-string

To check if the operator was good or not, I use this website : https://onlinestringtools.com/convert-decimal-to-string

推荐答案

使用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆