How to read a file
- In java the can be read by using the BufferedReader by which we can read the plain text document and other types of files.
- The process of reading the file is explained with a small program.
- In the above example, the BufferedReader is initialized to null to remove the Default value stored in it.
- The sCurrentLine variable is created to store the string that should be read from the file.
- Get a object for the BufferedReader (br) is created to perform the reading action and the path of the file is mentioned.
- The while condition is used to read the required content in the document and stores in the string variable.
- The final output of the program is
No comments:
Post a Comment