code: public static String getPropertyOrDefault(
        Class<?> referenceClass,
        String propertyFile,
        String key,
        String defaultValue) {
      try (InputStream stream = referenceClass.getResourceAsStream(propertyFile)) {
        if (stream == null) {
          logger.atSevere().log("Could not load properties file '%s'", propertyFile);
          return defaultValue;
        }
        Properties properties = new Properties();
        properties.load(stream);
        String value = properties.getProperty(key);
        if (value == null) {
          logger.atSevere().log("Key %s not found in properties file %s.", key, propertyFile);
          return defaultValue;
        }
        return value;
      } catch (IOException e) {
        logger.atSevere().withCause(e).log(
            "Error while trying to get property value for key %s", key);
        return defaultValue;
      }
    }
docs: Get the value of a property or a default value if there's an error retrieving the property key.
  @param referenceClass The class which should be used to find the property file. The property
  file is expected to be packaged in the same directory as this class.
  @param propertyFile The name of the property file to be read.
  @param key The property key to find in the property file.
  @param defaultValue The value to return if no property with the given key is found or if the
  property file cannot be found.
  @return The value specified in the property file or defaultValue if an error occurs or if the
  key could not be found