Writing data in Text File using Selenium Webdriver


public class WriteTextFile {

@Test
public void writetext() throws IOException
       {
//path to create new text file
String text="D:\\testexp1.txt";
       
                //File class in java is used for creating new file

File fc= new File(text);
fc.createNewFile();

//to write data filewriter class in java is used
FileWriter fw=new FileWriter(text);
BufferedWriter bw=new BufferedWriter(fw);
bw.write("This is selenium ");

bw.newLine();//for next line
bw.write("Webdriver");
bw.close();
System.out.println("Sucessfully written in txt file");
          }
}


Output:

Sucessfully written in txt file

PASSED: writetext

No comments:

Post a Comment