read text file in java

By | January 4, 2020

In this tutorial, we will look at how to read a text file in Java. We are using Files, BufferedReader and Scanner to read the file.

1. BufferedReader:

Output:

Selenium and Java Tutorials
Selenium Interview Questions
Selenium and Java Tutorials
Selenium Interview Questions

2. Using Files:

Output: 

Selenium and Java Tutorials
Selenium Interview Questions

3. Scanner:

Output:

Reading text file using Scanner class
Selenium and Java Tutorials
Selenium Interview Questions

 

Must reads:

Important methods in File class

How to delete a file in Java

Note: If you like selenium99 tutorials and would like to contribute any articles, please send your articles to techygeeks99@gmail.com.

Leave a Reply

Your email address will not be published. Required fields are marked *