package muttutest;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;
import java.util.Set;
public class Prop {
public static Properties loadPropertiesFile() throws Exception {
Properties prop = new Properties();
InputStream in = new FileInputStream(
"C:\\Users\\Mutturaj\\workspace\\maven-learn\\src\\test\\java\\muttutest\\muttu.properties");
prop.load(in);
in.close();
return prop;
}
public static void main(String[] args) {
try {
Properties properties = loadPropertiesFile();
Set<Object> set = properties.keySet();
for (Object o : set) {
String key = (String) o;
System.out.println("key: " + key + " value: " + properties.getProperty(key));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Tuesday, April 16, 2019
Get all keys and values from the properties file
Subscribe to:
Posts (Atom)