public class BufferedOutputStream extends FilterOutputStream
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buf
存储数据的内部缓冲区。
|
protected int |
count
缓冲区中有效字节的数量。
|
out| Constructor and Description |
|---|
BufferedOutputStream(OutputStream out)
创建一个新的缓冲输出流,以将数据写入指定的底层输出流。
|
BufferedOutputStream(OutputStream out, int size)
创建一个新的缓冲输出流,以便以指定的缓冲区大小将数据写入指定的底层输出流。
|
protected byte[] buf
protected int count
public BufferedOutputStream(OutputStream out)
out - 底层输出流。
public BufferedOutputStream(OutputStream out, int size)
out - 底层输出流。
size - 缓冲区大小。
IllegalArgumentException - 如果大小<= 0。
public void write(int b)
throws IOException
write在
FilterOutputStream
b - 要写入的字节。
IOException - 如果发生I / O错误。
public void write(byte[] b,
int off,
int len)
throws IOException
len个字节,从偏移off开始到缓冲的输出流。
通常,该方法将给定数组的字节存储到此流的缓冲区中,根据需要将缓冲区刷新到底层输出流。 然而,如果请求的长度至少与此流的缓冲区一样大,那么这个方法将刷新缓冲区并将字节直接写入底层的输出流。 因此冗余BufferedOutputStream不会不必要地复制数据。
write在
FilterOutputStream
b - 数据。
off - 数据中的起始偏移量。
len - 要写入的字节数。
IOException - 如果发生I / O错误。
FilterOutputStream.write(int)
public void flush()
throws IOException
flush在界面
Flushable
flush在
FilterOutputStream
IOException - 如果发生I / O错误。
FilterOutputStream.out
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.