public class packet { public int getByte(int start,byte b[]) { byte mb = b[start]; return mb<0 ? (int)mb + 256 : (int)mb; } public int getWord(int start,byte b[]) { return (getByte(start,b) << 8) | getByte(start+1,b); } public long getLong(int start,byte b[]) { return ((long)getByte(start,b) << 24) | ((long)getByte(start+1,b) << 16) | ((long)getByte(start+2,b) << 8) | (long)getByte(start+3,b); } }