在Java中,我只是将文件读入ByteBuffer.当我开始检查以确保ByteBuffer包含正确的字节时,我注意到它主要有正确的开始和结束字节,除了第3个字节,它有-117而不是emacs所说的应该是139(hexb中为8b) -模式).是什么赋予了?这与Big/Little Endian有关吗?
为了清楚起见,根据emacs,前四个字节应该是:
1f:8b:08:00等于31 139 8 0
我的java得到:
31 -117 8 0
有任何想法吗?
Java byte is signed, and therefore its range is -128..127 rather than 0..255. Taking that into account, your bytes are correct. If the unsigned value of the byte is X, signed one is (X - 256) - thus, for 139, the signed value is 139 - 256 = -117.
| 归档时间: |
|
| 查看次数: |
392 次 |
| 最近记录: |