static int bytes2int(byte[] b) { //byte[] b=new byte[]{1,2,3,4}; int mask=0xff; int temp=0; int res=0; for(int i=0;i<4;i++){ res<<=8; temp=b[i]&mask; res|=temp; } return res; } static byte[] int2bytes(int num) { byte[] b=new byte[4]; int mask=0xff; for(int i=0;i<4;i++){ b[i]=(byte)(num>>>(24-i*8)); } return b;
public class Main { public static void main(String[] args) { int i = 13223; System.out.println(Integer.toHexString(i)); byte[] b = new byte[4]; b[3]=(byte)(13223&0xff); i=i>>8; b[2]=(byte)(i&0xff); i=i>>8; b[1]=(byte)(i&0xff); i=i>>8; b[0]=(byte)(i&0xff); for(byte bb:b){ System.out.println(Integer.toHexString(bb)); } } }
楼主【shishlv】截止到2008-07-28 21:10:17的历史汇总数据(不包括此帖):
发帖的总数量:2 发帖的总分数:20 每贴平均分数:10
回帖的总数量:12 得分贴总数量:3 回帖的得分率:25%
结贴的总数量:1 结贴的总分数:0
无满意结贴数:1 无满意结贴分:20
未结的帖子数:1 未结的总分数:20
结贴的百分比:50.00 % 结分的百分比:0.00 %
无满意结贴率:100.00% 无满意结分率:---------------------
楼主加油
{
//byte[] b=new byte[]{1,2,3,4};
int mask=0xff;
int temp=0;
int res=0;
for(int i=0;i<4;i++){
res<<=8;
temp=b[i]&mask;
res|=temp;
}
return res;
} static byte[] int2bytes(int num)
{
byte[] b=new byte[4];
int mask=0xff;
for(int i=0;i<4;i++){
b[i]=(byte)(num>>>(24-i*8));
}
return b;
public class Main { public static void main(String[] args) {
int i = 13223;
System.out.println(Integer.toHexString(i));
byte[] b = new byte[4];
b[3]=(byte)(13223&0xff);
i=i>>8;
b[2]=(byte)(i&0xff);
i=i>>8;
b[1]=(byte)(i&0xff);
i=i>>8;
b[0]=(byte)(i&0xff);
for(byte bb:b){
System.out.println(Integer.toHexString(bb));
}
}
}