Saturday, March 28, 2020

Read properties file using ResourceBundle

package testngpractice;

import java.util.ResourceBundle;

import org.testng.annotations.Test;

public class PropertiesDemo {

@Test
public void showProp() {

ReadProperiesFile.getProperties("config", "name");

}
}

class ReadProperiesFile {

public static void getProperties(String filename, String key) {

ResourceBundle bundle = ResourceBundle.getBundle(filename);

System.out.println(bundle.getString(key));

}
}



Create a config.properties file in the Resource folder

No comments:

Post a Comment