How to read a file in java.
Hi All,
I am using Eclipse for java. I have to read a file. Here is my code.
The below code is in a ButtonHelper.java class:
public static String ClickButton(String locator){
try {
driver.findElement(By.xpath(locator)).click();
}catch (NoSuchElementException e) {
e.printStackTrace();
return "Fail - Click Button Not Found";
}
return "Pass";
}
In the above code, I have to read the locator from the another file called OR properties file. So how can I do that.
Help me guys.
Regards,
Sudheer
Re: How to read a file in java.
In the above code how to fail a test case if a loop is going into exception block.
Re: How to read a file in java.
1)Place [code=java] before your code and [/code] after your code.
2)Read over the FileReader class.
3)Once you familiarize yourself with that, try using the BufferedReader class.
Re: How to read a file in java.
Also you need to post the definitions for all the variables used in the posted code.
For example what is driver? Or By?