java里面怎么将Long[]转换为byte[]
我看别人把("10746350122311105403")转换出来为{-75,-121,118,-13,12,60,-114,-121,-126,-69,-53,-11,...
我看别人把("10746350122311105403")转换出来为
{ -75, -121, 118, -13, 12, 60, -114, -121, -126, -69, -53, -11,
-71, -111, 66, 88, -81, 80, -111, 5, 109, 15, -121, -110,
-61, -34, 107, 108, -92, -117, -65, 6, -104, -126, -7, 63,
-77, -9, -126, -52, -10, 62, -67, -4, 55, -71, 0, 88, -116,
74, 24, -94, 34, 127, -123, 117, -52, 38, -30, -19, -65,
-22, 36, 101 },
请问是怎么得出的呢 用的什么算法
比如我想把3714422464915877150long转为byte 展开
{ -75, -121, 118, -13, 12, 60, -114, -121, -126, -69, -53, -11,
-71, -111, 66, 88, -81, 80, -111, 5, 109, 15, -121, -110,
-61, -34, 107, 108, -92, -117, -65, 6, -104, -126, -7, 63,
-77, -9, -126, -52, -10, 62, -67, -4, 55, -71, 0, 88, -116,
74, 24, -94, 34, 127, -123, 117, -52, 38, -30, -19, -65,
-22, 36, 101 },
请问是怎么得出的呢 用的什么算法
比如我想把3714422464915877150long转为byte 展开
展开全部
//long类型转成byte数组
public static byte[] longToByte(long number) {
long temp = number;
byte[] b = new byte[8];
for (int i = 0; i < b.length; i++) {
b[i] = new Long(temp & 0xff).byteValue();//
将最低位保存在最低位
temp = temp >> 8; // 向右移8位
}
return b;
}
public static byte[] longToByte(long number) {
long temp = number;
byte[] b = new byte[8];
for (int i = 0; i < b.length; i++) {
b[i] = new Long(temp & 0xff).byteValue();//
将最低位保存在最低位
temp = temp >> 8; // 向右移8位
}
return b;
}
追问
具体要怎么操作 把这代码复制到哪里。。。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询