这里说明两三个实例,后面的看源代码就很清晰了。
1.readBoolean()
public final boolean readBoolean() throws IOException {
int ch = in.read();
if (ch < 0)
throw new EOFException();
return (ch != 0);
}
由于DataInputStream是FilterInputStream,所以里面有一个基本流 in,首先调用in.read()方法
在java.io.InputStream类的read()的API说明:
/**
* Reads the next byte of data from the input stream. The value byte is
* returned as an <code>int</code> in the range <code>0</code> to
* <code>255</code>. If no byte is available because the end of the stream
* has been reached, the value <code>-1</code> is returned. This method
* blocks until input data is available, the end of the stream is detected,
* or an exception is thrown.
*
* <p> A subclass must provide