1. Create a property file using New > File > Given name - like config.properties (it must be saved with .properties).
2. Add data in config.properties like:
browser = chrome
environment = qa
3. Add a class to read the property file (see below class)
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
public class ReadingProperties {
static FileInputStream fis;
static Properties prop;
public static String getValueOfPropertyFile(String value) throws IOException {
fis = new FileInputStream("-------Path of the property file-------");
prop = new Properties();
prop.load(fis);
return prop.getProperty(value);
}
}
4. Where you want to read the data just call - ReadingProperties.getValueOfPropertyFile("----pass the key which you want from property file").
The function will return to the value of that key.