This Generic loads a properties file to the application and reads the values from the properties file.
import java.util.Properties; import java.io.InputStream; import java.io.IOException; public class PropertiesValueLoader { private static Properties defaults = new Properties(); InputStream in= null; public void loadVariable(String propertyFile)throws IOException { in=this.getClass().getClassLoader() .getResourceAsStream(propertyFile); try{ if (in != null) { defaults.load (in); } } catch (IOException e) { defaults = null; } finally { if (in != null) try { in.close (); } catch (IOException e) {} } } public String getValue(String field) { String value = defaults.getProperty(field); if (value == null) { return null; } return value.trim(); } public int getValueInt(String field) { String value = defaults.getProperty(field); int intValue=0; if (value == null) { return intValue; } intValue=Integer.parseInt(value.trim()); return intValue; } }