Я начинаю с Selenium, я создал имя класса для чтения под названием ReadPropertyFile
. В этом классе я написал код для чтения файла config.properties
. Теперь у меня есть основной класс, где я хочу назвать класс ReadPropertyFile
и их активность, из которой я могу прочитать файл config.properties
.Как читать файл conf.properties из другого класса?
Пожалуйста, помогите мне, как это сделать ниже код:
ReadPropertyFile.java:
public class ReadPropertyFile {
public static void main(String[] arg)throws IOException{
// Read configuration properties file
String projdir = System.getProperty("user.dir");
String propfilepath = projdir+"\\configuration\\"+"conf.properties";
Properties p = new Properties();
p.load(new FileInputStream(propfilepath));
String url = p.getProperty("URL");
System.out.println(url); // It is returning me a value corresponding to key "test"
String driverFilePath = p.getProperty("DRIVER_FILE_PATH");
System.out.println(driverFilePath);
String testSuite = p.getProperty("TEST_SUITE");
System.out.println(testSuite);
}
}
MainClass.java
public class MainClass {
static Properties properties= new Properties();
public static void main(String[] args) {
// TODO Auto-generated method stub
ReadPropertyFile readConfigFile= new ReadPropertyFile();
}
}