あるフリーランスエンジニアの色んなメモ!! ITスキル・ライフハックとか

Java:オブジェクトのByte配列をプリミティブなbyte配列に変換する

Maven設定

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.11</version>
        </dependency>

実装例

import org.apache.commons.lang.ArrayUtils;


Byte[] binaryObj;
...
byte[] binary = ArrayUtils.toPrimitive((Byte[]) binaryObj);
comments powered by Disqus