Java 日看一类(25)之IO包中的FilterOutputStream类
2018-03-16 14:46
441 查看
该类继承自OutputStream类
无引入包
类头注释如下:/**
* This class is the superclass of all classes that filter output
* streams. These streams sit on top of an already existing output
* stream (the <i>underlying</i> output stream) which it uses as its
* basic sink of data, but possibly transforming the data along the
* way or providing additional functionality.
* <p>
* The class <code>FilterOutputStream</code> itself simply overrides
* all methods of <code>OutputStream</code> with versions that pass
* all requests to the underlying output stream. Subclasses of
* <code>FilterOutputStream</code> may further override some of these
* methods as well as provide additional methods and fields.
*
* @author Jonathan Payne
* @since JDK1.0
*/大意如下:
这个类是所有过滤输出流类的祖先
这些流位于所有已存在的输出流(底层输出流)之上,使用基础类型的数据
但也可能改变数据的类型或者提供一些额外的方法
FilterOutputStream类对那些将所有请求都传递给底层输出流的OutputStream方法做了简单的覆写
以该类作为基类的类可能会覆写该类的方法并且提供额外的方法和参数
该类含有如下成员变量:
该类的底层输出流protected OutputStream out;
该类含有如下的成员方法:
构造方法(过滤传入的输出流public FilterOutputStream(OutputStream out) {
this.out = out;
}写出一个字节public void write(int b) throws IOException {
out.write(b);
}写出一个byte数组public void write(byte b[]) throws IOException {
write(b, 0, b.length);
}写出该byte数组中特定位置和长度的数据public void write(byte b[], int off, int len) throws IOException {
if ((off | len | (b.length - (len + off)) | (off + len)) < 0)
throw new IndexOutOfBoundsException();
for (int i = 0 ; i < len ; i++) {
write(b[off + i]);
}
}刷新输出流(将输出流中的数据输出public void flush() throws IOException {
out.flush();
}关闭输出流(关闭前先讲输出流中的数据写出public void close() throws IOException {
try (OutputStream ostream = out) {
flush();
}
}
该类仅做了一些简单的覆写,主体还是OutputStream,大概看看就行,主要关注子类
无引入包
类头注释如下:/**
* This class is the superclass of all classes that filter output
* streams. These streams sit on top of an already existing output
* stream (the <i>underlying</i> output stream) which it uses as its
* basic sink of data, but possibly transforming the data along the
* way or providing additional functionality.
* <p>
* The class <code>FilterOutputStream</code> itself simply overrides
* all methods of <code>OutputStream</code> with versions that pass
* all requests to the underlying output stream. Subclasses of
* <code>FilterOutputStream</code> may further override some of these
* methods as well as provide additional methods and fields.
*
* @author Jonathan Payne
* @since JDK1.0
*/大意如下:
这个类是所有过滤输出流类的祖先
这些流位于所有已存在的输出流(底层输出流)之上,使用基础类型的数据
但也可能改变数据的类型或者提供一些额外的方法
FilterOutputStream类对那些将所有请求都传递给底层输出流的OutputStream方法做了简单的覆写
以该类作为基类的类可能会覆写该类的方法并且提供额外的方法和参数
该类含有如下成员变量:
该类的底层输出流protected OutputStream out;
该类含有如下的成员方法:
构造方法(过滤传入的输出流public FilterOutputStream(OutputStream out) {
this.out = out;
}写出一个字节public void write(int b) throws IOException {
out.write(b);
}写出一个byte数组public void write(byte b[]) throws IOException {
write(b, 0, b.length);
}写出该byte数组中特定位置和长度的数据public void write(byte b[], int off, int len) throws IOException {
if ((off | len | (b.length - (len + off)) | (off + len)) < 0)
throw new IndexOutOfBoundsException();
for (int i = 0 ; i < len ; i++) {
write(b[off + i]);
}
}刷新输出流(将输出流中的数据输出public void flush() throws IOException {
out.flush();
}关闭输出流(关闭前先讲输出流中的数据写出public void close() throws IOException {
try (OutputStream ostream = out) {
flush();
}
}
该类仅做了一些简单的覆写,主体还是OutputStream,大概看看就行,主要关注子类
相关文章推荐
- Java 日看一类(1)之IO包中的Bits
- Java 日看一类(20)之IO包中的FilePermission类与FilePermissionCollection类
- Java 日看一类(31)之IO包中的InvalidClassException异常类和IOError异常类
- Java 日看一类(11)之IO包中的DataInputStream类
- Java 日看一类(30)之IO包中的InterruptedIOException、InvalidObjectException异常类
- Java 日看一类(29)之IO包中的InputStreamReader类
- Java 日看一类(16) 之IO包中的FileDescriptor类
- Java 日看一类 (33)之IO包中的LineNumberReader类
- Java 日看一类(26)之IO包中的FilterReader类
- Java 日看一类(9)之IO包中的CharConversionException类和Console类
- Java 日看一类(24)之IO包中的FilterInputStream类
- Java 日看一类(19)之IO包中的FileOutputStream类
- Java 日看一类(23)之IO包中的FileWriter类
- Java 日看一类(3)之IO包中的BufferedOutputStream类
- Java 日看一类(18)之IO包中的FileNameFilter接口类和FileNotFoundException异常类
- Java 日看一类(27)之IO包中的FIlterWriter类
- Java 日看一类(8)之IO包中的Ch 4000 arArrayReader类
- Java 日看一类(4)之IO包中的BufferedReader类
- Java 日看一类(5)之IO包中的BufferedWriter类
- Java 日看一类(34)之IO包中的NotActiveException和NotSerializableException