你可以进到readInt()方法里面看一下 public final int readInt() throws IOException { int ch1 = this.read(); int ch2 = this.read(); int ch3 = this.read(); int ch4 = this.read(); if ((ch1 | ch2 | ch3 | ch4) < 0) throw new EOFException(); return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0)); }Reads a byte of data from this file. public native int read() throws IOException;本质上还是一个一个的读字节,然后通过位移运算把这些字节按java语言所规定的高低位进行调整计算出来的
public final int readInt() throws IOException {
int ch1 = this.read();
int ch2 = this.read();
int ch3 = this.read();
int ch4 = this.read();
if ((ch1 | ch2 | ch3 | ch4) < 0)
throw new EOFException();
return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
}Reads a byte of data from this file.
public native int read() throws IOException;本质上还是一个一个的读字节,然后通过位移运算把这些字节按java语言所规定的高低位进行调整计算出来的
throws IOException从此文件读取一个有符号的 32 位整数。此方法从该文件的当前文件指针开始读取 4 个字节。如果按顺序读取的字节为 b1、b2、b3 和 b4,其中 0 <= b1, b2, b3, b4 <= 255,则结果将等于:
(b1 << 24) | (b2 << 16) + (b3 << 8) + b4
DataInputStream里的readInt时格式是这样的[int的长度][int数字的值]