问题描述
我发现了很多与此主题有关的问题,但无法解决我的问题.
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
推荐答案
使用 String#chars()
:
List<Integer> intName = currentName.chars()
.boxed().collect(toList());
这篇关于将字符串转换为字节然后转换为int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!