Read-Write Text File In Java - Tutorials For WebDriver

We bring learnt almost String degree too Its dissimilar functions In my previous post. Now our side past times side topic Is How to write In to text file or How to read text file In java software evolution language. Many times you lot volition require reading or writing text file In your selenium webdriver software automation show instance development. For Example, You are reading approximately large data from spider web page of software spider web application too wants to shop It In text file to exercise It somewhere else In future. Same way, You bring to read information from file for approximately purpose.

It Is really slow to Create, Write too read text file In coffee software evolution language. We tin exercise coffee built inward class File to practice novel file, FileWriter and BufferedWriter class to write In to file, FileReader and BufferedReader class to read text file. 

Bellow given representative volition commencement of all create temp.txt file In D: displace too thence write 2 business In to It. Then It volition read both lines i past times i from text file using acre loop too impress In console. You tin exercise bellow given representative code of software evolution linguistic communication for reading or writing text file In your selenium webdriver software automation show instance whenever needed.

import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException;  world degree RW_File {   world static void main(String[] args) throws IOException {   //Create File In D: Driver.     String TestFile = "D:\\temp.txt";   File FC = novel File(TestFile);//Created object of coffee File class.   FC.createNewFile();//Create file.      //Writing In to file.   //Create Object of coffee FileWriter too BufferedWriter class.   FileWriter FW = novel FileWriter(TestFile);   BufferedWriter BW = novel BufferedWriter(FW);   BW.write("This Is First Line."); //Writing In To File.   BW.newLine();//To write side past times side string on novel line.   BW.write("This Is Second Line."); //Writing In To File.   BW.close();      //Reading from file.   //Create Object of coffee FileReader too BufferedReader class.   FileReader FR = novel FileReader(TestFile);   BufferedReader BR = novel BufferedReader(FR);   String Content = "";      //Loop to read all lines i past times i from file too impress It.   while((Content = BR.readLine())!= null){    System.out.println(Content);   }  } }

This agency nosotros tin read too write text file In coffee for your selenium webdriver show instance development.
More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM

http://www.software-testing-tutorials-automation.com/
Post a Comment (0)
Previous Post Next Post