Read two bytes into an integer?
问题 I have a byte[] that I've read from a file, and I want to get an int from two bytes in it. Here's an example: byte[] bytes = new byte[] {(byte)0x00, (byte)0x2F, (byte)0x01, (byte)0x10, (byte)0x6F}; int value = bytes.getInt(2,4); //This method doesn't exist This should make value equal to 0x0110 , or 272 in decimal. But obviously, byte[].getInt() doesn't exist. How can I accomplish this task? The above array is just an example. Actual values are unknown to me. 回答1: You should just opt for the