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;
    }
}
相關文章
相關標籤/搜索