How to convert byte[] to Byte[] and the other way around?

前端 未结 7 665
小鲜肉
小鲜肉 2020-12-02 10:18

How to convert byte[] to Byte[] and also Byte[] to byte[], in the case of not using any 3rd party library?

Is the

相关标签:
7条回答
  • 2020-12-02 10:58

    If someone preferes Stream API over ordinary loops.

    private Byte[] toObjects(byte[] bytes) {
        return IntStream.range(0, bytes.length)
                .mapToObj(i -> bytes[i])
                .toArray(Byte[]::new);
    }
    
    0 讨论(0)
提交回复
热议问题