This chapter discusses Java's FileReader and BufferedReader classes in detail. FileReader and BufferedReader classes are used together when reading data from an external file. The use of the BufferedReader class allows data to be buffered as it is read from a file before manipulating it. The readLine() method of the BufferedReader class reads a line of text from a character-oriented input stream, and puts it into a new String object.
Answer:
FileReader and BufferedReader
FileReader
is used for input of character data from a disk file. The input file can be an ordinary ASCII, one byte per character text file. A Reader
stream automatically translates the characters from the disk file format into the internal char
format.
The characters in the input file might be from other alphabets supported by the UTF format, in which case there will be up to four bytes per character. In this case, also, characters from the file are translated into char
format.
As with output, it is good practice to use a buffer to improve efficiency. Use BufferedReader for this.
Question 3:
What method reads a line of characters from a
BufferedReader
?