java - 方法的 "general contract"是什么

标签 java

我正在查看 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 the writeBoolean method of interface DataOutput.

因此您应该期望 DataInputStream.readBoolean 以这种方式运行。

关于java - 方法的 "general contract"是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27758341/

相关文章:

java - 对象在Java游戏中应该如何

java - 更快的 contains() 操作的数据结构?

java - 如何扩展 AbstractScheduledService.Scheduler

Javax 验证 : Constraint Violations for Map

java - 有没有办法覆盖 openjpa 中的 javax.persistence.EntityManager.persist() 方法

java - .method() 没有引用

java - Spring项目-在jsp页面中显示mysql表数据

java - 如何使用 SASL_SSL 连接 Apache Kafka 设置 Spring Cloud Kafka 项目?

java - 从给定的 1 和 0 字符串中获取一个字节

java - net.ucanaccess.triggers.TriggerException : Table does not exists.:Z_2015_02_24