Thursday 23 March 2017

Read Config.Proprties file

How to Read Config.properties File with Key & Value Pair




public String readPropertyOf(String key){

String propValue = null;
try {
FileInputStream input = new FileInputStream("./config.properties");
Properties prop = new Properties();
prop.load(input);
propValue = prop.getProperty(key);
} catch (IOException e) {
System.out.println("Caught the below exception!");
e.printStackTrace();
}
return propValue;

}




public static void main(String[] args)
{
   String readname =   readPropertyOf("name");
    System.out.println(readname);

  }

No comments:

Post a Comment