【问题标题】:convert byte array to short array [closed]将字节数组转换为短数组[关闭]
【发布时间】:2018-05-27 05:19:15
【问题描述】:

我想将 byte 数组转换为 short 数组。请给我一个解决方案。

【问题讨论】:

  • 解决办法是学编程,写代码。不要在这里问离题的问题。我们不是编码服务。
  • 另外,这个问题与Android没有任何关系。
  • 用什么编程语言?

标签: arrays type-conversion


【解决方案1】:

您可以像这样使用 ByteBuffer 将字节数组转换为短数组

byte[] bytes = {};
short[] shorts = new short[bytes.length/2]; 
ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer().get(shorts);

【讨论】:

    猜你喜欢
    • 2012-06-04
    • 1970-01-01
    • 2023-04-02
    • 1970-01-01
    • 2013-11-04
    • 1970-01-01
    • 2013-08-23
    • 2017-03-13
    • 2012-02-15
    相关资源
    最近更新 更多