byte의 hexa 데이터를 int형으로 출력해야하는대 byte를int로 출력하는 소스를 참고하려고 했는데..의미를 모르겟습니다.
이소스를 이용해서 값을 출력했는데...제가 원하는 결과값과는 달라서 참고를 해서 바꿔야할것같은데........해서좀 부탁드립니다.
public static int byteArrayToInt(byte[] bytes) {
final int size = Integer.SIZE / 8;
ByteBuffer buff = ByteBuffer.allocate(size);
final byte[] newBytes = new byte[size];
for (int i = 0; i < size; i++) {
if (i + bytes.length < size) {
newBytes[i] = (byte) 0x00;
} else {
newBytes[i] = bytes[i + bytes.length - size];
}
}
buff = ByteBuffer.wrap(newBytes);
buff.order(ByteOrder.BIG_ENDIAN);
return buff.getInt();
} //byteArrayToInt