static byte[] readFile(File sfile) {
return FileUtils.readFileToByteArray(sfile)
}
static String byte2string(byte[] b, int start, int end) {
StringBuilder s = new StringBuilder();
for (int i = 0; i < (end - start); i++) {
s.append((char) b[i + start]);
}
return s.toString();
}
static int getInt(byte[] b, int start, int end) {
int v = getUInt(b, start, end);
if ((int) b[end] < 0) // is a negative
v -= 1 << (end - start + 1) * 8;
return v;
}
static int getUInt(byte[] b, int start, int end) {
int v = 0;
for (int i = start; i <= end; i++) {
int k = i - start;
int j = (int) b[i] >= 0 ? b[i] : ((int) b[i] + 256) % 256;
v += j << (k * 8);
}
return v;
}