Java examples for java.util:Properties File
get Property Value from Property file
//package com.java2s; import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; public class Main { public static void main(String[] argv) throws Exception { String propertyName = "java2s.com"; System.out.println(getPropertyValue(propertyName)); }// ww w .j a v a2 s . co m public static String getPropertyValue(String propertyName) throws IOException { String result = ""; Properties prop = new Properties(); String propFileName = "src/main/resources/config.properties"; prop.load(new FileInputStream(propFileName)); // get the property value and print it out result = prop.getProperty(propertyName); return result; } }