声明:本系列只供本人自学使用,勿喷。
处理流,是以节点流(文件、管道、字节/字符数组)为基础构造的流,可以对节点流进行特殊的处理,常用的处理流有:缓冲流(BufferedInputStream、BufferedOutputStream、BufferedReader、BufferedWriter)、基本数据流(DataInputStream、DataOutputStream)。
本节先讲解父类

一、FilterInputStream
- 构造器
public class FilterInputStream extends InputStream{
protected volatile InputStream in;
// 必须以InputStream为基础构造
protected FilterInputStream(InputStream in) {
this.in = in;
}
}
- 方法
/********实际调用的都是入参 InputStream 的方法************/
public int read() throws IOException
public int read(byte b[]) throws IOException
public int read(byte b[], int off, int len) throws IOException
public long skip(long n) throws IOException
public int available() throws IOException
public void close() throws IOException
public synchronized void mark(int readlimit)
public synchronized void reset() throws IOException
public boolean markSupported()
二、FilterOutputStream
- 构造器
public class FilterOutputStream extends OutputStream {
protected OutputStream out;
// 必须以 OutputStream 为基础构造
public FilterOutputStream(OutputStream out) {
this.out = out;
}
}
- 方法
/********实际调用的都是入参 OutputStream的方法************/
public void write(int b) throws IOException
public void write(byte b[]) throws IOException
public void write(byte b[], int off, int len) throws IOException
public void flush() throws IOException
public void close() throws IOException
三、FilterReader
- 构造器
public abstract class FilterReader extends Reader {
protected Reader in;
// 必须以 Reader 为基础构造
protected FilterReader(Reader in) {
super(in);
this.in = in;
}
}
- 方法
/********实际调用的都是入参 Reader 的方法************/
public int read() throws IOException
public int read(char cbuf[], int off, int len) throws IOException
public long skip(long n) throws IOException
public boolean ready() throws IOException
public boolean markSupported()
public void mark(int readAheadLimit) throws IOException
public void reset() throws IOException
public void close() throws IOException
四、FilterWriter
- 构造器
public abstract class FilterWriter extends Writer {
protected Writer out;
// 必须以 Writer 为基础构造
protected FilterWriter(Writer out) {
super(out);
this.out = out;
}
}
- 方法
/********实际调用的都是入参 Writer 的方法************/
public void write(int c) throws IOException
public void write(char cbuf[], int off, int len) throws IOException
public void write(String str, int off, int len) throws IOException
public void flush() throws IOException
public void close() throws IOException
网友评论