public interface Channel extends Closeable
一个通道表示一个开放的连接到一个实体,如硬件设备,文件,网络插座,或一个程序组件,是能够执行一个或多个不同的I / O操作,例如阅读或写作。
通道是打开或关闭的。一个通道在创建时打开,一旦关闭,它仍然关闭。一旦通道关闭,任何试图调用一个I/O操作后,它会造成ClosedChannelException
被。是否一个信道的开放性可以通过调用其isOpen
法测试。
通道,在一般情况下,为了安全的多线程访问的接口和类,扩展和实现这个接口的规范中所描述的。
boolean isOpen()
void close() throws IOException
在一个通道关闭,任何试图调用I/O操作后,它会造成ClosedChannelException
被。
如果这个通道已经关闭,则调用该方法没有效果。
这种方法可能在任何时候被调用。如果一些其他线程已经调用它,那么另一个调用将被阻止,直到第一次调用完成,之后它将返回没有效果。
close
接口
AutoCloseable
close
接口
Closeable
IOException
如果I/O错误发生
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.