Big-Edian 存储和 Little-Edian 存储

在 JVM 虚拟机规范中有对 class 字节内容的顺序的一句话,多字节数据项总是按照 Big-Endian 的顺序进行存储,刚开始不太明白,只是根据规范解析了一下,具体的java 代码:

1
2
3
4
5
6
7
8
9
10
11
12
13

public ClassReadCursor(String filePath, ClassParseInfo classParseInfo) {
try {
this.classParseInfo = classParseInfo;
byte[] bytes = Files.readAllBytes(Paths.get(filePath));
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes).order(ByteOrder.BIG_ENDIAN);
this.dataInputStream = new DataInputStream(new ByteArrayInputStream(byteBuffer.array()));
} catch (IOException e) {
e.printStackTrace();
}

}

阅读更多