java io系列10之 FilterInputStream
2016-09-13 16:30
465 查看
FilterInputStream 介绍
FilterInputStream 的作用是用来“封装其它的输入流,并为它们提供额外的功能”。它的常用的子类有BufferedInputStream和DataInputStream。BufferedInputStream的作用就是为“输入流提供缓冲功能,以及mark()和reset()功能”。
DataInputStream 是用来装饰其它输入流,它“允许应用程序以与机器无关方式从底层输入流中读取基本 Java 数据类型”。应用程序可以使用DataOutputStream(数据输出流)写入由DataInputStream(数据输入流)读取的数据。
FilterInputStream 源码(基于jdk1.7.40)
package java.io; public class FilterInputStream extends InputStream { protected volatile InputStream in; protected FilterInputStream(InputStream in) { this.in = in; } public int read() throws IOException { return in.read(); } public int read(byte b[]) throws IOException { return read(b, 0, b.length); } public int read(byte b[], int off, int len) throws IOException { return in.read(b, off, len); } public long skip(long n) throws IOException { return in.skip(n); } public int available() throws IOException { return in.available(); } public void close() throws IOException { in.close(); } public synchronized void mark(int readlimit) { in.mark(readlimit); } public synchronized void reset() throws IOException { in.reset(); } public boolean markSupported() { return in.markSupported(); } }
相关文章推荐
- java io系列10之 FilterInputStream
- java io系列10之 FilterInputStream
- java io系列10之 FilterInputStream
- java io系列10之 FilterInputStream
- Java总结(10)的IO(二)
- android基础篇------------java基础(10)(IO)
- JAVA IO系列---DataInputStream和DataOutputstream类
- JAVA IO系列----ObjectInputStream和ObjectOutputStream类
- JAVA IO系列----PipedInputStream与PipedOutputStream类,PipedWriter和PipedReader类
- java io系列09之 FileDescriptor总结
- 黑马程序员-JAVA高级视频_IO输入与输出-19天-10(读取转换流)
- java io系列04之 管道(PipedOutputStream和PipedInputStream)的简介,源码分析和示例
- java io系列11之 FilterOutputStream
- 读mingjava io系列文章有感
- java io系列05之 ObjectInputStream 和 ObjectOutputStream
- java io系列07之 FileInputStream和FileOutputStream
- java io系列01之 "目录"
- JAVA IO系列----FileInputStream和FileOutputStream类,Reader和Writer类
- JAVA IO系列----节点流
- JAVA高级视频02_IO输入与输出日记3(02-06到10)