InputStream接口的常见实现类

一. FileInputStreamthis

  FileInputStream能够从系统文件中获取输入字节,也从能够从诸从图象数据的的原始字节流中读取。 若是是读取字符串流,推荐使用FileReader。spa

感受就是视频,音频,图象之类的文件,就用FileInputStream读取。而若是是纯文字(字符串)文件就用FileReader读取。code

  

二. FilterInputStream视频

   对其它的InputStream输入流进行包装,将其做为基础数据源,可能会对其进行数据转换或者提供某些额外功能,对FilterInputStream对象的操做,其实是对其包装的inputStream进行操做。对象

public class FilterInputStream extends InputStream {
    /**
     * The input stream to be filtered.
     */
    protected volatile InputStream in;

    /**
     * Creates a <code>FilterInputStream</code>
     * by assigning the  argument <code>in</code>
     * to the field <code>this.in</code> so as
     * to remember it for later use.
     *
     * @param   in   the underlying input stream, or <code>null</code> if
     *          this instance is to be created without an underlying stream.
     */
    protected FilterInputStream(InputStream in) {
        this.in = in;
    }
}
相关文章
相关标签/搜索