In this section, you will learn how to read a file into the string.
Description of code:
You can use any input stream but it is better to use FileReader class for reading the textual input. In the given example we have used BufferedReader class along with FileReader class to read data from the file using it's read() method. This data is then stored into the StringBuffer. At last, we have extracted the string from the StringBuffer and displayed it on the console.
Here is the code:
In the above code we have used FileReader and BufferedReader class to read the file into memory.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.