「Java」longを8byte配列に変換するサンプルコード

 Javaコード
public static byte[] longToByte8(long lo) {
byte[] targets = new byte[8];
for (int i = 0; i < 8; i++) {
int offset = (targets.length – 1 – i) * 8;
targets[i] = (byte) ((lo >>> offset) & 0xFF);
}
return targets;
}

Java

Posted by arkgame