⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 javaio.doc3.html

📁 java语言规范
💻 HTML
字号:
<html>
<head>
<title>The Java Language Specification The Package java.io </title>
</head>
<body BGCOLOR=#eeeeff text=#000000 LINK=#0000ff VLINK=#000077 ALINK=#ff0000>
 
<a href="index.html">Contents</a> | <a href="javaio.doc2.html">Prev</a> | <a href="javaio.doc4.html">Next</a> | <a href="j.index.doc1.html">Index</a>
<hr><br>
 
<a name="28307"></a>
<center><h1>22.5  The Class  <code>java.io.PipedInputStream</code></h1></center>
<a name="28308"></a>
A piped input stream should be connected to a piped output stream; the piped 
input stream then provides whatever data bytes are written to the piped output 
stream. Typically, data is read from a <code>PipedInputStream</code> object by one thread 
and data is written to the corresponding <code>PipedOutputStream</code> <a href="javaio.doc15.html#29449">(&#167;22.17)</a> by some 
other thread. Attempting to use both objects from a single thread is not recommended,
as it may deadlock the thread. The piped input stream contains a buffer, 
decoupling read operations from write operations, within limits.
<p><pre><a name="28309"></a>public class <code><b>PipedInputStream</b></code> extends InputStream {
<a name="28310"></a>	public <code><b>PipedInputStream</b></code>(PipedOutputStream src)
<a name="28311"></a>		throws IOException;
<a name="28312"></a>	public <code><b>PipedInputStream</b></code>();
<a name="28313"></a>	public void <code><b>connect</b></code>(PipedOutputStream src)
<a name="28314"></a>		throws IOException;
<a name="28315"></a>	public int <code><b>read</b></code>() throws IOException;
<a name="28316"></a>	public int <code><b>read</b></code>(byte[] b, int off, int len) 
<a name="28317"></a>		throws IOException, NullPointerException,
<a name="32303"></a>			IndexOutOfBoundsException;
<a name="28318"></a>	public void <code><b>close</b></code>() throws IOException;
<a name="28319"></a>}
</pre><a name="28320"></a>
<p><font size=+1><strong>22.5.1   </strong> <code>public <code><b>PipedInputStream</b></code>(PipedOutputStream src)<br>throws IOException</code></font>
<p>
<a name="28321"></a>
This constructor initializes a newly created <code>PipedInputStream</code> so that it is connected
to the piped output stream <code>src</code>. Data bytes written to <code>src</code> will then be 
available as input from this stream.
<p><a name="28322"></a>
<p><font size=+1><strong>22.5.2   </strong> <code>public <code><b>PipedInputStream</b></code>()</code></font>
<p>
<a name="28323"></a>
This constructor initializes a newly created <code>PipedInputStream</code> so that it is not 
yet connected. It must be connected to a <code>PipedOutputStream</code> before being used.
<p><a name="28324"></a>
<p><font size=+1><strong>22.5.3   </strong> <code>public void <code><b>connect</b></code>(PipedOutputStream src)<br>throws IOException</code></font>
<p>
<a name="28325"></a>
The <code>connect</code> method causes this piped input stream to be connected to the piped 
output stream <code>src</code>. If this object is already connected to some other piped output 
stream, an <code>IOException</code> is thrown.
<p><a name="28326"></a>
If <code>src</code> is an unconnected piped output stream and <code>snk</code> is an unconnected piped input stream, they may be connected by either the call:<p>
<pre><a name="28327"></a>snk.connect(src)
</pre><a name="28328"></a>
or the call:
<p><pre><a name="28329"></a>src.connect(snk)
</pre><a name="28330"></a>
The two calls have the same effect.
<p><a name="28331"></a>
<p><font size=+1><strong>22.5.4   </strong> <code>public int <code><b>read</b></code>() throws IOException</code></font>
<p>
<a name="28332"></a>
If a thread was providing data bytes to the connected piped output stream, but the 
thread is no longer alive, then an <code>IOException</code> is thrown.
<p><a name="28336"></a>
Implements the <code>read</code> method of <code>InputStream</code> <a href="javaio.doc1.html#28142">(&#167;22.3.1)</a>.<p>
<a name="28337"></a>
<p><font size=+1><strong>22.5.5   </strong> <code>public int <code><b>read</b></code>(byte[] b, int off, int len)<br>throws IOException, NullPointerException,  &#32; &#32; &#32;IndexOutOfBoundsException</code></font>
<p>
<a name="28338"></a>
If a thread was providing data bytes to the connected piped output stream, but the 
thread is no longer alive, then an <code>IOException</code> is thrown.
<p><a name="28342"></a>
Overrides the <code>read</code> method of <code>InputStream</code> <a href="javaio.doc1.html#28164">(&#167;22.3.3)</a>.<p>
<a name="28343"></a>
<p><font size=+1><strong>22.5.6   </strong> <code>public void <code><b>close</b></code>() throws IOException</code></font>
<p>
<a name="28344"></a>
This piped input stream is closed and may no longer be used for reading bytes.
<p><a name="28348"></a>
Overrides the <code>close</code> method of <code>InputStream</code> <a href="javaio.doc1.html#28187">(&#167;22.3.6)</a>.<p>


<hr>
<!-- This inserts footnotes--><p>
<a href="index.html">Contents</a> | <a href="javaio.doc2.html">Prev</a> | <a href="javaio.doc4.html">Next</a> | <a href="j.index.doc1.html">Index</a>
<p>
<font size=-1>Java Language Specification (HTML generated by Suzette Pelouch on February 24, 1998)<br>
<i><a href="jcopyright.doc.html">Copyright &#169 1996 Sun Microsystems, Inc.</a>
All rights reserved</i>
<br>
Please send any comments or corrections to <a href="mailto:doug.kramer@sun.com">doug.kramer@sun.com</a>
</font>
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -