This is the code I found about reading bytes from Stream.
import java.io.*;
InputStream in = new FileInputStream("f://myfile.txt");
int b;
while ((b = in.read()) != -1) {
System.out.println("The next byte is " + b);
}
in.close();
Although, we know that we're dealing specifically with a FileInputStream,why we are referring an instance of FileInputStream as an instance of InputStream?
InputStream in = new FileInputStream("f://myfile.txt");
//rest of the code
Instead of simply doing this:
FileInputStream in = new FileInputStream("f://myfile.txt");
//rest of the code
if I am correct, then this is called Upcasting because we are casting an object of subclass type to its super class? But why are we doing this??
Does it enhance the performance?
Same thing is done in this Answer(Download Files from internet) while downloading files form internet in Android.