📄 javaio.doc18.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.doc17.html">Prev</a> | <a href="javaio.doc19.html">Next</a> | <a href="j.index.doc1.html">Index</a>
<hr><br>
<a name="9059"></a>
<center><h1>22.20 The Class <code>java.io.BufferedOutputStream</code></h1></center>
<a name="24554"></a>
A <code>BufferedOutputStream</code> adds functionality to another output stream, namely
the ability to buffer the output. When the <code>BufferedOutputStream</code> is created, an
internal buffer array is created. As bytes are written to the stream, they are stored
in the internal buffer, which is flushed as necessary, thereby performing output to
the contained output stream in large blocks rather than a byte at a time.
<p><pre><a name="9060"></a>public class <code><b>BufferedOutputStream</b></code> extends FilterOutputStream {
<a name="9061"></a> protected byte[] <code><b>buf</b></code>;
<a name="9062"></a> protected int <code><b>count</b></code>;
<a name="9063"></a> public <code><b>BufferedOutputStream</b></code>(OutputStream out);
<a name="9064"></a> public <code><b>BufferedOutputStream</b></code>(OutputStream out, int size);
<a name="9065"></a> public void <code><b>write</b></code>(int b) throws IOException;
<a name="24530"></a> public void <code><b>write</b></code>(byte[] b)
<a name="32452"></a> throws IOException, NullPointerException;
<a name="24535"></a> public void <code><b>write</b></code>(byte[] b, int off, int len)
<a name="24536"></a> throws IOException, NullPointerException,
<a name="32451"></a> IndexOutOfBoundsException;
<a name="9067"></a> public void <code><b>flush</b></code>() throws IOException;
<a name="9068"></a>}
</pre><a name="9069"></a>
<p><font size=+1><strong>22.20.1 </strong> <code>protected byte[] <code><b>buf</b></code>;</code></font>
<p>
<a name="24544"></a>
The internal buffer array.
<p><a name="9070"></a>
<p><font size=+1><strong>22.20.2 </strong> <code>protected int <code><b>count</b></code>;</code></font>
<p>
<a name="24550"></a>
This value is always in the range <code>0</code> through <code>buf.length</code>; elements <code>buf[0]</code>
through <code>buf[count-1] </code>contain valid byte data.
<p><a name="9071"></a>
<p><font size=+1><strong>22.20.3 </strong> <code>public <code><b>BufferedOutputStream</b></code>(OutputStream out)</code></font>
<p>
<a name="24576"></a>
This constructor initializes a newly created <code>BufferedOutputStream</code> by saving its
argument, the input stream <code>out</code>, for later use. An internal buffer array is created
and stored in <code>buf</code>.
<p><a name="9072"></a>
<p><font size=+1><strong>22.20.4 </strong> <code>public <code><b>BufferedOutputStream</b></code>(OutputStream out, int size)</code></font>
<p>
<a name="24583"></a>
This constructor initializes a newly created <code>BufferedOutputStream</code> by saving its
argument, the input stream <code>out</code>, for later use. An internal buffer array of length
<code>size</code> is created and stored in <code>buf</code>.
<p><a name="9073"></a>
<p><font size=+1><strong>22.20.5 </strong> <code>public void <code><b>write</b></code>(int b) throws IOException</code></font>
<p>
<a name="24613"></a>
See the general contract of the <code>write</code> method of <code>OutputStream</code> <a href="javaio.doc13.html#29411">(§22.15.1)</a>.
<p><a name="24617"></a>
Overrides the <code>write</code> method of <code>FilterOutputStream</code> <a href="javaio.doc17.html#29666">(§22.19.3)</a>.<p>
<a name="24595"></a>
<p><font size=+1><strong>22.20.6 </strong> <code>public void <code><b>write</b></code>(byte[] b)<br>throws IOException, NullPointerException</code></font>
<p>
<a name="24629"></a>
See the general contract of the <code>write</code> method of <code>OutputStream</code> <a href="javaio.doc13.html#29419">(§22.15.2)</a>.
<p><a name="24633"></a>
Overrides the <code>write</code> method of <code>FilterOutputStream</code> <a href="javaio.doc17.html#29673">(§22.19.4)</a>.<p>
<a name="24599"></a>
<p><font size=+1><strong>22.20.7 </strong> <code>public void <code><b>write</b></code>(byte[] b, int off, int len)<br>throws IOException, NullPointerException,      IndexOutOfBoundsException</code></font>
<p>
<a name="24640"></a>
See the general contract of the <code>write</code> method of <code>OutputStream</code> <a href="javaio.doc13.html#29426">(§22.15.3)</a>.
<p><a name="24644"></a>
Overrides the <code>write</code> method of <code>FilterOutputStream</code> <a href="javaio.doc17.html#29680">(§22.19.5)</a>.<p>
<a name="9075"></a>
<p><font size=+1><strong>22.20.8 </strong> <code>public void <code><b>flush</b></code>() throws IOException</code></font>
<p>
<a name="24652"></a>
See the general contract of the <code>flush</code> method of <code>OutputStream</code> <a href="javaio.doc13.html#29440">(§22.15.4)</a>.
<p><a name="24656"></a>
Overrides the <code>flush</code> method of <code>FilterOutputStream</code> <a href="javaio.doc17.html#29687">(§22.19.6)</a>.<p>
<hr>
<!-- This inserts footnotes--><p>
<a href="index.html">Contents</a> | <a href="javaio.doc17.html">Prev</a> | <a href="javaio.doc19.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 © 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 + -