Skip to main content

Posts

Showing posts from October, 2020
Reading the data from a text file in Java and Selenium : There are two approaches where we can get the data from the text file that is file reader and buffered reader  this class allows us to get the data from the text file with the methods of its implementation like read() and readline() Code: Which can read the data character by character using the method read() public class filereader_character { public static void main(String[] args) throws Exception { FileReader reader = new FileReader("E:\\eclipseprojects\\Demoprojects\\seleniuminterviewQA\\testfile\\test.txt"); int character; while((character = reader.read()) != -1) { System.out.print((char) character); } reader.close(); } } Code: Which can read the data by string line using the method readline() public class filerreader_lines { public static void main(String[] args) throws IOException { FileReader reader1 = new FileReader("E:\\eclipseprojects\\Demoprojects\\seleniuminterviewQA\\testfil...