|
|
|
@ -23,8 +23,8 @@ public class BytesArrayTools {
|
|
|
|
|
* @param value long to write
|
|
|
|
|
*/
|
|
|
|
|
public static void write(byte[] array, int start, long value) {
|
|
|
|
|
for(int i=0;i<4;i++) {
|
|
|
|
|
array[start + i] = (byte) ((value >> (8 * (4 - i))) & 0xFF);
|
|
|
|
|
for(int i=0;i<8;i++) {
|
|
|
|
|
array[start + i] = (byte) ((value >> (8 * (7 - i))) & 0xFF);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -36,7 +36,7 @@ public class BytesArrayTools {
|
|
|
|
|
public static int readInt(byte[] array, int start) throws SizeError {
|
|
|
|
|
int size = 0;
|
|
|
|
|
for(int i=0;i<4;i++) {
|
|
|
|
|
size |= ((int)array[start + i]) << (8* i);
|
|
|
|
|
size |= ((int)array[start + i]) << (8* (3 -i));
|
|
|
|
|
}
|
|
|
|
|
if (size < 0) {
|
|
|
|
|
// Size in array is probably correct
|
|
|
|
@ -53,7 +53,7 @@ public class BytesArrayTools {
|
|
|
|
|
public static long readLong(byte[] array, int start) throws SizeError {
|
|
|
|
|
long size = 0;
|
|
|
|
|
for(int i=0;i<8;i++) {
|
|
|
|
|
size |= ((int)array[start + i]) << (8* i);
|
|
|
|
|
size |= ((int)array[start + i]) << (8* (7 - i));
|
|
|
|
|
}
|
|
|
|
|
if (size < 0) {
|
|
|
|
|
// Size in array is probably correct
|
|
|
|
|