|
JavaTM Platform Standard Ed. 6 |
|||||||||
��һ���� ��һ���� | ��� ��� ������ | |||||||||
ժҪ�� Ƕ�� | �ֶ� | ���췽�� | ���� | ��ϸ��Ϣ�� �ֶ� | ���췽�� | ���� |
java.lang.Objectjava.io.InputStream
java.io.PipedInputStream
public class PipedInputStream
�ܵ�������Ӧ�����ӵ��ܵ���������ܵ��������ṩҪд��ܵ�����������������ֽڡ�ͨ����������ij���̴߳� PipedInputStream
�����ȡ�����������߳̽���д�뵽��Ӧ�� PipedOutputStream
���������������������ʹ�õ����̣߳���Ϊ�������������̡߳��ܵ�����������һ�������������ڻ��������ķ�Χ�ڽ���������д�������뿪��
��������ӹܵ�������ṩ�����ֽڵ��̲߳��ٴ��ڣ�����Ϊ�ùܵ�������
PipedOutputStream
�ֶ�ժҪ | |
---|---|
protected byte[] |
buffer
���ô������ݵ�ѭ���������� |
protected int |
in
ѭ����������λ�õ��������������ӵĹܵ�������н��յ���һ�������ֽ�ʱ���Ὣ��洢����λ�á� |
protected int |
out
ѭ����������λ�õ��������˹ܵ����������Ӹ�λ�ö�ȡ��һ�������ֽڡ� |
protected static int |
PIPE_SIZE
�ܵ�ѭ�����뻺������Ĭ�ϴ�С�� |
���췽��ժҪ | |
---|---|
PipedInputStream()
����������� PipedInputStream �� |
|
PipedInputStream(int pipeSize)
����һ����δ������ PipedInputStream �����Թܵ�������ʹ��ָ���Ĺܵ���С�� |
|
PipedInputStream(PipedOutputStream src)
���� PipedInputStream ��ʹ�����ӵ��ܵ������ src �� |
|
PipedInputStream(PipedOutputStream src,
int pipeSize)
����һ�� PipedInputStream ��ʹ�����ӵ��ܵ������ src �����Թܵ�������ʹ��ָ���Ĺܵ���С�� |
����ժҪ | |
---|---|
int |
available()
���ؿ��Բ��������شӴ��������ж�ȡ���ֽ����� |
void |
close()
�رմ˹ܵ����������ͷ��������ص�����ϵͳ��Դ�� |
void |
connect(PipedOutputStream src)
ʹ�˹ܵ����������ӵ��ܵ������ src �� |
int |
read()
��ȡ�˹ܵ��������е���һ�������ֽڡ� |
int |
read(byte[] b,
int off,
int len)
����� len �������ֽڴӴ˹ܵ����������� byte ���顣 |
protected void |
receive(int b)
���������ֽڡ� |
���� java.io.InputStream �̳еķ��� |
---|
mark, markSupported, read, reset, skip |
���� java.lang.Object �̳еķ��� |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
�ֶ���ϸ��Ϣ |
---|
protected static final int PIPE_SIZE
protected byte[] buffer
protected int in
in<0
��ζ�Ż�����Ϊ�գ�in==out
��ζ�Ż�����������
protected int out
���췽����ϸ��Ϣ |
---|
public PipedInputStream(PipedOutputStream src) throws IOException
PipedInputStream
��ʹ�����ӵ��ܵ������ src
��� src
�������ֽڿ��������������롣
src
- Ҫ���ӵ�����
IOException
- ������� I/O ����public PipedInputStream(PipedOutputStream src, int pipeSize) throws IOException
PipedInputStream
��ʹ�����ӵ��ܵ������ src
�����Թܵ�������ʹ��ָ���Ĺܵ���С��
� src
�������ֽڿ��������������롣
src
- Ҫ���ӵ�����pipeSize
- �ܵ��������Ĵ�С��
IOException
- ������� I/O ����
IllegalArgumentException
- ��� pipeSize <= 0
��public PipedInputStream()
PipedInputStream
����ʹ��ǰ���뽫�������� PipedOutputStream
��
public PipedInputStream(int pipeSize)
PipedInputStream
�����Թܵ�������ʹ��ָ���Ĺܵ���С����ʹ��ǰ���뽫�������� PipedOutputStream
��
pipeSize
- �ܵ��������Ĵ�С��
IllegalArgumentException
- ��� pipeSize <= 0
��������ϸ��Ϣ |
---|
public void connect(PipedOutputStream src) throws IOException
src
������˶����Ѿ����ӵ�����ij���ܵ�����������׳� IOException
��
��� src
Ϊδ���ӵĹܵ��������snk
Ϊδ���ӵĹܵ��������������ͨ��������һ����ʹ�����ӣ�
snk.connect(src)
��
src.connect(snk)
���������õ�Ч����ͬ��
src
- Ҫ���ӵĹܵ��������
IOException
- ������� I/O ����protected void receive(int b) throws IOException
b
- �����յ��ֽ�
IOException
- ����ܵ���
�����
���رգ����߷��� I/O ����public int read() throws IOException
0
�� 255
��Χ�ڵ� int
�ֽ�ֵ�����������ݿ��á�������ĩβ�����׳��쳣ǰ���˷���һֱ������
InputStream
�е� read
-1
��
IOException
- ����ܵ�δ����
����
���رգ����߷��� I/O ����public int read(byte[] b, int off, int len) throws IOException
len
�������ֽڴӴ˹ܵ����������� byte ���顣����ѵ�����������ĩβ������ len
�����ܵ���������С�����ȡ���ֽ��������� len
����� len
Ϊ 0����ȡ�κ��ֽڲ����� 0������������ 1 �������ֽڿ��á�����ĩβ���׳��쳣ǰ���÷�����һֱ������
InputStream
�е� read
b
- �������ݵĻ�������off
- Ŀ������ b
�еij�ʼƫ������len
- ��ȡ������ֽ�����
-1
��
NullPointerException
- ��� b
Ϊ null
��
IndexOutOfBoundsException
- ��� off
����len
�������� len
���� b.length - off
IOException
- ����ܵ���
�����
���رգ����߷��� I/O ����InputStream.read()
public int available() throws IOException
InputStream
�е� available
close()
�����رմ����������ܵ�δ����
������
���� 0
��
IOException
- ������� I/O ����public void close() throws IOException
Closeable
�е� close
InputStream
�е� close
IOException
- ������� I/O ����
|
JavaTM Platform Standard Ed. 6 |
|||||||||
��һ���� ��һ���� | ��� ��� ������ | |||||||||
ժҪ�� Ƕ�� | �ֶ� | ���췽�� | ���� | ��ϸ��Ϣ�� �ֶ� | ���췽�� | ���� |
��Ȩ���� 2007 Sun Microsystems, Inc. ��������Ȩ���� ����������֤��������������ĵ����·ַ�������