聲明:本系列只供本人自學(xué)使用,勿噴赡矢。
處理流杭朱,是以節(jié)點流(文件、管道吹散、字節(jié)/字符數(shù)組)為基礎(chǔ)構(gòu)造的流弧械,可以對節(jié)點流進(jìn)行特殊的處理,常用的處理流有:緩沖流(BufferedInputStream空民、BufferedOutputStream刃唐、BufferedReader、BufferedWriter)界轩、基本數(shù)據(jù)流(DataInputStream画饥、DataOutputStream)。
本節(jié)先講解父類
一浊猾、FilterInputStream
- 構(gòu)造器
public class FilterInputStream extends InputStream{
protected volatile InputStream in;
// 必須以InputStream為基礎(chǔ)構(gòu)造
protected FilterInputStream(InputStream in) {
this.in = in;
}
}
- 方法
/********實際調(diào)用的都是入?yún)?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
- 構(gòu)造器
public class FilterOutputStream extends OutputStream {
protected OutputStream out;
// 必須以 OutputStream 為基礎(chǔ)構(gòu)造
public FilterOutputStream(OutputStream out) {
this.out = out;
}
}
- 方法
/********實際調(diào)用的都是入?yún)?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
- 構(gòu)造器
public abstract class FilterReader extends Reader {
protected Reader in;
// 必須以 Reader 為基礎(chǔ)構(gòu)造
protected FilterReader(Reader in) {
super(in);
this.in = in;
}
}
- 方法
/********實際調(diào)用的都是入?yún)?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
- 構(gòu)造器
public abstract class FilterWriter extends Writer {
protected Writer out;
// 必須以 Writer 為基礎(chǔ)構(gòu)造
protected FilterWriter(Writer out) {
super(out);
this.out = out;
}
}
- 方法
/********實際調(diào)用的都是入?yún)?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