Thursday, 16 June 2016

Setting and getting System Properties in Java

To set the System property

System.setProperty("p1","v1");

Loading System properties from a settings file say xyz.properties

Properties prop = new Properties();

try {
InputStream inputStream = URLReader.class.getClassLoader().
getResourceAsStream("xyz.properties");
prop.load(inputStream);
} catch (IOException ex) {

}

Reading System property


System.getProperty("os.name")
System.getProperty("user.dir");

Similarly we can read user.timezone, user.home, java.version, file.separator

Reading all System properties


System.getProperties().list(System.out);

What do you think on above selenium topic. Please provide your inputs and comments. You can write to me at reply2sagar@gmail.com

No comments:

Post a Comment

Buy Best Selenium Books

About Me

My photo

Self-motivated software professional