Most visited

Recently visited

Added in API level 1

PipedReader

public class PipedReader
extends Reader

java.lang.Object
    java.io.Reader
      java.io.PipedReader


管道字符输入流。

摘要(Summary)

Inherited fields

From class java.io.Reader

Public constructors

PipedReader(PipedWriter src)

创建一个 PipedReader以便它连接到管道 src

PipedReader(PipedWriter src, int pipeSize)

创建一个 PipedReader以便它连接到管道 src并使用管道缓冲区的指定管道大小。

PipedReader()

创建一个 PipedReader以便它尚未 connected

PipedReader(int pipeSize)

创建一个 PipedReader ,使其尚未 connected并使用管道缓冲区的指定管道大小。

公共方法(Public methods)

void close()

关闭此管道流并释放与该流关联的所有系统资源。

void connect(PipedWriter src)

导致此管道读取器连接到管道 src

int read()

从此管道流读取数据的下一个字符。

int read(char[] cbuf, int off, int len)

将最多 len来自此管道流的数据字符读入到字符数组中。

boolean ready()

判断这个流是否准备好被读取。

继承方法(Inherited methods)

From class java.io.Reader
From class java.lang.Object
From interface java.lang.Readable
From interface java.io.Closeable
From interface java.lang.AutoCloseable

Public constructors

PipedReader

Added in API level 1
PipedReader (PipedWriter src)

创建一个PipedReader以便它连接到管道src 写入src数据将作为此流的输入。

参数(Parameters)
src PipedWriter: the stream to connect to.
抛出异常(Throws)
IOException if an I/O error occurs.

PipedReader

Added in API level 9
PipedReader (PipedWriter src, 
                int pipeSize)

创建一个PipedReader以便它连接到管道src并使用管道缓冲区的指定管道大小。 写入src数据将作为此流的输入。

参数(Parameters)
src PipedWriter: the stream to connect to.
pipeSize int: the size of the pipe's buffer.
抛出异常(Throws)
IOException if an I/O error occurs.
IllegalArgumentException if pipeSize <= 0.

PipedReader

Added in API level 1
PipedReader ()

创建一个PipedReader以便它尚未connected 在使用之前,它必须是connectedPipedWriter

PipedReader

Added in API level 9
PipedReader (int pipeSize)

创建一个PipedReader以便它尚未connected并使用管道缓冲区的指定管道大小。 在使用之前,它必须是connectedPipedWriter

参数(Parameters)
pipeSize int: the size of the pipe's buffer.
抛出异常(Throws)
IllegalArgumentException if pipeSize <= 0.

公共方法(Public methods)

close

Added in API level 1
void close ()

关闭此管道流并释放与该流关联的所有系统资源。

抛出异常(Throws)
IOException if an I/O error occurs.

connect

Added in API level 1
void connect (PipedWriter src)

导致此管道读取器连接到管道src 如果此对象已连接到某个其他管道作家, IOException抛出IOException

如果 src是未连接的管道 snk器,并且 snk是未连接的管道读取器,则可以通过以下任一方式连接它们:

snk.connect(src) 

或电话:

src.connect(snk) 

这两个调用具有相同的效果。

参数(Parameters)
src PipedWriter: The piped writer to connect to.
抛出异常(Throws)
IOException if an I/O error occurs.

read

Added in API level 1
int read ()

从此管道流读取数据的下一个字符。 如果由于已到达流的末尾而没有字符可用,则返回值-1 此方法阻塞直到输入数据可用,流的末尾被检测到,或抛出异常。

返回(Returns)
int the next character of data, or -1 if the end of the stream is reached.
抛出异常(Throws)
IOException if the pipe is broken, unconnected, closed, or an I/O error occurs.

read

Added in API level 1
int read (char[] cbuf, 
                int off, 
                int len)

将最多len字符的数据从此管道流读取到字符数组中。 如果数据流的末尾已达到或者len超过管道的缓冲区大小,将读取少于len字符。 此方法阻塞,直到至少有一个输入字符可用。

参数(Parameters)
cbuf char: the buffer into which the data is read.
off int: the start offset of the data.
len int: the maximum number of characters read.
返回(Returns)
int the total number of characters read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
抛出异常(Throws)
IOException if the pipe is broken, unconnected, closed, or an I/O error occurs.

ready

Added in API level 1
boolean ready ()

判断这个流是否准备好被读取。 如果循环缓冲区不为空,则管道字符流已准备就绪。

返回(Returns)
boolean True if the next read() is guaranteed not to block for input, false otherwise. Note that returning false does not guarantee that the next read will block.
抛出异常(Throws)
IOException if the pipe is broken, unconnected, or closed.

Hooray!