what is the difference in using InputStream instead of FileInputStream while creating the FileInputStream object

后端 未结 5 1019
天涯浪人
天涯浪人 2021-02-02 13:54

This may be a silly one, but I want to know the background operation difference.

  1. InputStream is = new FileInputStream(filepath);
  2. FileIn
5条回答
  •  Happy的楠姐
    2021-02-02 14:19

    There is no difference. In each case you are creating a FileInputStream. The first is probably better programming style in that you should generally use a classes interface instead of the concrete class to allow for flexibility (i.e you decide to use a BufferedInputStream).

提交回复
热议问题