JavaTM Platform
Standard Ed. 6

java.io
�� PipedInputStream

java.lang.Object
  �̳��� java.io.InputStream
      �̳��� java.io.PipedInputStream
������ʵ�ֵĽӿڣ�
Closeable

public class PipedInputStream
extends InputStream

�ܵ�������Ӧ�����ӵ��ܵ���������ܵ��������ṩҪд��ܵ�����������������ֽڡ�ͨ����������ij���̴߳� PipedInputStream �����ȡ�����������߳̽���д�뵽��Ӧ�� PipedOutputStream���������������������ʹ�õ����̣߳���Ϊ�������������̡߳��ܵ�����������һ�������������ڻ������޶��ķ�Χ�ڽ���������д�������뿪�� ��������ӹܵ�������ṩ�����ֽڵ��̲߳��ٴ��ڣ�����Ϊ�ùܵ�������

�����°汾��ʼ��
JDK1.0
������
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
 

�ֶ���ϸ��Ϣ

PIPE_SIZE

protected static final int PIPE_SIZE
�ܵ�ѭ�����뻺������Ĭ�ϴ�С��

�����°汾��ʼ��
JDK1.1
������
�����ֶ�ֵ

buffer

protected byte[] buffer
���ô������ݵ�ѭ����������

�����°汾��ʼ��
JDK1.1

in

protected int in
ѭ����������λ�õ��������������ӵĹܵ�������н��յ���һ�������ֽ�ʱ���Ὣ��洢����λ�á�in<0 ��ζ�Ż�����Ϊ�գ�in==out ��ζ�Ż�����������

�����°汾��ʼ��
JDK1.1

out

protected int out
ѭ����������λ�õ��������˹ܵ����������Ӹ�λ�ö�ȡ��һ�������ֽڡ�

�����°汾��ʼ��
JDK1.1
���췽����ϸ��Ϣ

PipedInputStream

public PipedInputStream(PipedOutputStream src)
                 throws IOException
���� PipedInputStream��ʹ�����ӵ��ܵ������ src��д�� src �������ֽڿ��������������롣

������
src - Ҫ���ӵ�����
�׳���
IOException - ������� I/O ����

PipedInputStream

public PipedInputStream(PipedOutputStream src,
                        int pipeSize)
                 throws IOException
����һ�� PipedInputStream��ʹ�����ӵ��ܵ������ src�����Թܵ�������ʹ��ָ���Ĺܵ���С�� д�� src �������ֽڿ��������������롣

������
src - Ҫ���ӵ�����
pipeSize - �ܵ��������Ĵ�С��
�׳���
IOException - ������� I/O ����
IllegalArgumentException - ��� pipeSize <= 0��
�����°汾��ʼ��
1.6

PipedInputStream

public PipedInputStream()
������δ������ PipedInputStream����ʹ��ǰ���뽫�������� PipedOutputStream��


PipedInputStream

public PipedInputStream(int pipeSize)
����һ����δ������ PipedInputStream�����Թܵ�������ʹ��ָ���Ĺܵ���С����ʹ��ǰ���뽫�������� PipedOutputStream��

������
pipeSize - �ܵ��������Ĵ�С��
�׳���
IllegalArgumentException - ��� pipeSize <= 0��
�����°汾��ʼ��
1.6
������ϸ��Ϣ

connect

public void connect(PipedOutputStream src)
             throws IOException
ʹ�˹ܵ����������ӵ��ܵ������ src������˶����Ѿ����ӵ�����ij���ܵ�����������׳� IOException��

��� src Ϊδ���ӵĹܵ��������snk Ϊδ���ӵĹܵ��������������ͨ��������һ����ʹ�����ӣ�

snk.connect(src) 

��

src.connect(snk) 

���������õ�Ч����ͬ��

������
src - Ҫ���ӵĹܵ��������
�׳���
IOException - ������� I/O ����

receive

protected void receive(int b)
                throws IOException
���������ֽڡ���������ڿ��õ����룬�˷���������������

������
b - �����յ��ֽ�
�׳���
IOException - ����ܵ�����δ�������رգ����߷��� I/O ����
�����°汾��ʼ��
JDK1.1

read

public int read()
         throws IOException
��ȡ�˹ܵ��������е���һ�������ֽڡ����� 0 �� 255 ��Χ�ڵ� int �ֽ�ֵ�����������ݿ��á���⵽����ĩβ�����׳��쳣ǰ���˷���һֱ������

ָ���ߣ�
�� InputStream �е� read
���أ�
��һ�������ֽڣ�����ѵ�����ĩβ���򷵻� -1��
�׳���
IOException - ����ܵ�δ�����������رգ����߷��� I/O ����

read

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()

available

public int available()
              throws IOException
���ؿ��Բ��������شӴ��������ж�ȡ���ֽ�����

���ǣ�
�� InputStream �е� available
���أ�
���Բ��������شӴ���������ȡ���ֽ���������Ѿ����� close() �����رմ����������ܵ�δ�������������򷵻� 0��
�׳���
IOException - ������� I/O ����
�����°汾��ʼ��
JDK1.0.2

close

public void close()
           throws IOException
�رմ˹ܵ����������ͷ��������ص�����ϵͳ��Դ��

ָ���ߣ�
�ӿ� Closeable �е� close
���ǣ�
�� InputStream �е� close
�׳���
IOException - ������� I/O ����

JavaTM Platform
Standard Ed. 6

�ύ��������
�йظ���� API �ο����ϺͿ�����Ա�ĵ�������� Java SE ������Ա�ĵ������ĵ���������ϸ�ġ����򿪷���Ա���������Լ�������������ﶨ�塢ʹ�ü��ɺ͹�������ʾ����

��Ȩ���� 2007 Sun Microsystems, Inc. ��������Ȩ���� ����������֤��������������ĵ����·ַ�������