This may be a silly one, but I want to know the background operation difference.
InputStream is = new FileInputStream(filepath);
FileIn
FileInputStream
extends InputStream
: it is a specialized version of an InputStream designed for reading files.
There are several implementations of an InputStream according to the use of it.
It is usually good practice to use the highest type needed in your code. Therefore if your code needs to read data from an InputStream
but not specifically from a FileInputStream
, you should use InputStream
. Yet if you do need to keep the information of your object being a FileInputStream
and not just an InputStream
, then you should keep the FileInputStream
type.