我想从 java.io.InputStream 中读取超时。显然正确的方法是使用 java.nio.channels.SelectableChannel 和 java.nio.channels.Selector。不幸的是,尚不清楚如何从 InputStream 转到 SelectableChannel。
InputStream 来自非常规来源——http://java.sun.com/products/javacomm/reference/api/javax/comm/CommPort.html#getInputStream()