gpt4 book ai didi

java - 将字节数组转换为 List

转载 作者:IT老高 更新时间:2023-10-28 21:18:55 25 4
gpt4 key购买 nike

我能想到这些,

  1. Arrays.asList(byte[])转换 byte[]List<byte[]> ,
  2. 遍历字节数组并将每个元素添加到列表中

我只是想知道是否有任何库函数可以做到这一点?

最佳答案

图书馆 Apache Commons Lang有 ArrayUtils.toObject,它将原始数组转换为类型化对象数组:

int array[] = { 1, 2, 3 };
List<Integer> list = Arrays.asList(ArrayUtils.toObject(array));

关于java - 将字节数组转换为 List<Byte>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4231674/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com