Govt. Exams
Entrance Exams
Filter streams are chained from inside-out. FileReader is wrapped with BufferedReader for better performance.
The readLine() method reads a line of text from the BufferedReader, returning a String without the newline character, or null if end of stream is reached.
FileNotFoundException (a subclass of IOException) is thrown when the specified file does not exist or cannot be opened.
The read() method returns an int. It returns the byte value (0-255) or -1 if end of stream is reached. This is why it needs to be cast to byte if needed.
The flush() method forces any buffered output to be written to the underlying stream immediately without closing it.
The read() method reads a single byte and returns it as an integer. Returns -1 if end of stream is reached.
FileReader is a character stream class that reads characters from a file. FileInputStream, DataInputStream, and BufferedInputStream are byte stream classes.