How to convert byte[] to Byte[], and also Byte[] to byte[], in the case of not using any 3rd party library? Is there a way to do it fast just using the standard library?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
From byte[] to Byte[]:
From Byte[] to byte[] (using our previously-defined
B
):Byte
class is a wrapper for the primitivebyte
. This should do the work:byte[] to Byte[] :
Byte[] to byte[] :
Inverse:
You could use the toPrimitive method in the Apache Commons lang library ArrayUtils class, As suggested here - Java - Byte[] to byte[]
Java 8 solution:
Unfortunately, you can't do this to convert from
Byte[]
tobyte[]
.Arrays
hassetAll
fordouble[]
,int[]
, andlong[]
, but not for other primitive types.