Most visited

Recently visited

Added in API level 1

Pipe

public abstract class Pipe
extends Object

java.lang.Object
    java.nio.channels.Pipe


一对实现单向管道的通道。

一个管道由一对通道组成:一个可写的 sink通道和一个可读的 source通道。 一旦一些字节写入接收通道,就可以按照写入的顺序从源通道读取它们。

无论是将字节写入管道的线程是否会阻塞,直到另一个线程从管道中读取这些字节或某些先前写入的字节,都取决于系统,因此未指定。 许多管道实现会在接收器和源通道之间缓冲一定数量的字节,但不应假定这种缓冲。

摘要(Summary)

Nested classes

class Pipe.SinkChannel

表示Pipe的可写结束的Pipe 。

class Pipe.SourceChannel

表示Pipe的可读端的Pipe 。

Protected constructors

Pipe()

初始化此类的新实例。

公共方法(Public methods)

static Pipe open()

打开管道。

abstract Pipe.SinkChannel sink()

返回此管道的接收器通道。

abstract Pipe.SourceChannel source()

返回此管道的源通道。

继承方法(Inherited methods)

From class java.lang.Object

Protected constructors

Pipe

Added in API level 1
Pipe ()

初始化此类的新实例。

公共方法(Public methods)

open

Added in API level 1
Pipe open ()

打开管道。

新管道通过调用系统范围的默认 SelectorProvider对象的 openPipe方法创建。

返回(Returns)
Pipe A new pipe
抛出异常(Throws)
IOException If an I/O error occurs

sink

Added in API level 1
Pipe.SinkChannel sink ()

返回此管道的接收器通道。

返回(Returns)
Pipe.SinkChannel This pipe's sink channel

source

Added in API level 1
Pipe.SourceChannel source ()

返回此管道的源通道。

返回(Returns)
Pipe.SourceChannel This pipe's source channel

Hooray!