我正在查看 DataInputStream
的 Java 文档这里:http://docs.oracle.com/javase/7/docs/api/java/io/DataInputStream.html
我想看看它的方法是做什么的,所以我查看了 readBoolean()
的描述, readByte()
, readChar()
等等
描述都是这样的:
See the general contract of the readBoolean method of DataInput.
并在扩展说明中。
public final boolean readBoolean()
throws IOException
See the general contract of the readBoolean method of DataInput.
Bytes for this operation are read from the contained input stream.
Specified by:
readBoolean in interface DataInput
Returns:
the boolean value read.
Throws:
EOFException - if this input stream has reached the end.
IOException - the stream has been closed and the contained input stream does not support reading after close, or another I/O error occurs.
See Also:
FilterInputStream.in
从哪里可以“看到”这些方法的总契约,什么是方法的总契约?
最佳答案
这只是意味着DataInput.readBoolean
的文档包含更多细节。该文档特别指出:
Reads one input byte and returns
true
if that byte is nonzero,false
if that byte is zero. This method is suitable for reading the byte written by thewriteBoolean
method of interfaceDataOutput
.
因此您应该期望 DataInputStream.readBoolean
以这种方式运行。
关于java - 方法的 "general contract"是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27758341/