I was reading about Java I/O and found some interesting areas like streams, readers etc.
InputStream input = new FileInputStream("input-file.txt");
int data = input.read();
while(data != -1){
data = input.read();
}
I can do the same thing by using Readers as follows:
Reader reader = new FileReader("input-file.txt");
int data = reader.read();
while(data != -1){
char dataChar = (char) data;
data = reader.read();
}
As I know, Streams are used to retrieve input from continuously flowing data.
Now I am confused with the difference between Streams & readers; and if we wraps the stream with a buffered reader - how it break lines, since stream is a continuously flowing thing.
I found some reference sites like this site. But I can't understand the difference.
Please can someone please help me to understand?