Java - Properties

java

Properties properties = new Properties();
properties.load(new FileInputStream(new File(fileName)));
String server = properties.getProperty("PROPERTY_NAME");

How to read a .properties file?

private Properties getAdminProperties(String fileName) throws Exception {
    Properties properties = new Properties();
    properties.load(new FileInputStream(new File(fileName)));
    //properties.load(FileFinder.getResourceAsStream(fileName));
    return properties;
}

How to access a particular property from a Properties object?

Properties ap = getAdminProperties(cs.getRealPath("plugins\\CustomTask\\WEB-INF\\classes\\adminCredential.properties"));
server = ap.getProperty("ISERVER");
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License