27 lines
681 B
Java

package com.alterdekim.flash.decompiler.util;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class ByteUtil {
public static int bytesToInt(byte[] bytes) {
int value = 0;
for (byte b : bytes) {
value = (value << 8) + (b & 0xFF);
}
return value;
}
public static int bytesToIntRev(byte[] bytes) {
int value = 0;
for(int i = bytes.length-1; i >= 0; i-- ) {
value = (value << 8) + (bytes[i] & 0xFF);
}
return value;
}
public static double bytesToDouble(byte[] bytes) {
return ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).getDouble();
}
}