How to Export Notepad Data Using Selenium Example Program?

How do you export Notepad data using the Selenium example program?

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class WorkingwithFiles
{
   public static void main(String[] args) 
   {
      //FilePath
      String sFilePath = "D:\\Automation\\Selenium\\TestFile.txt"; 
      //Creating FileReader object
      FileReader fr = null;
      //Creating BufferedReader object
      BufferedReader txtReader = null;
      //Handling Exception using Try-Catch
      try 
      {
         String sCurrentLine;
         fr = new FileReader(sFilePath);
         txtReader = new BufferedReader(fr);
         //Reading file until file is null
         while ((sCurrentLine = txtReader.readLine()) != null) {
            System.out.println(sCurrentLine);
         }
      } 
      catch (IOException e) {
         e.printStackTrace();
      } 
      finally {
         try {
            if (txtReader != null)txtReader.close();
         } catch (IOException ex) {
            ex.printStackTrace();
         }
      }
   }
}

Avatar for Softwaretestingo Editorial Board

I love open-source technologies and am very passionate about software development. I like to share my knowledge with others, especially on technology that's why I have given all the examples as simple as possible to understand for beginners. All the code posted on my blog is developed, compiled, and tested in my development environment. If you find any mistakes or bugs, Please drop an email to softwaretestingo.com@gmail.com, or You can join me on Linkedin.

1 thought on “How to Export Notepad Data Using Selenium Example Program?”

Leave a Comment