2010. 6. 29. 17:26
public static int swapLittleEndian(byte[] bytes) {
int newValue = 0;
newValue |= (((int)bytes[3])<<24)&0xFF000000;
newValue |= (((int)bytes[2])<<16)&0xFF0000;
newValue |= (((int)bytes[1])<<8)&0xFF00;
newValue |= (((int)bytes[0]))&0xFF;
return newValue;
}
int newValue = 0;
newValue |= (((int)bytes[3])<<24)&0xFF000000;
newValue |= (((int)bytes[2])<<16)&0xFF0000;
newValue |= (((int)bytes[1])<<8)&0xFF00;
newValue |= (((int)bytes[0]))&0xFF;
return newValue;
}
'java > util' 카테고리의 다른 글
[java] - byte array to int (0) | 2010.06.29 |
---|---|
[java] - int to byte array (0) | 2010.06.29 |
[java] - Little Endian to Big Endian (0) | 2010.06.29 |
[java] - float to byte array (1) | 2010.06.29 |
[java] - byte array to float (0) | 2010.06.29 |