Load the property File
Properties prop = new Properties(); String propFileName = "/opt/my.properties"; try(InputStream inputStream = new FileInputStream(propFileName)) { prop.load(inputStream); }
Now get the Integer Value from the loaded property File
* * @param prop * @param propertyNameInFile * @param defaultValue * @return the value from the file or the default value */ private static int getIntegerValueFromFile(Properties prop, String propertyNameInFile, int defaultValue) { String propertyValueInFile = prop.getProperty(propertyNameInFile); int value = defaultValue; if (StringUtils.isNotBlank(propertyValueInFile)) { try { value = Integer.parseInt(propertyValueInFile); } catch (Exception e) { logger.error(e, e); } } return value; }