/** * Loads properties from a resource. * * @param resource url of the properties file * @return a set of properties on success, or null if failed */ @Nullable public static Properties loadPropertiesFromResource(URL resource) { try (InputStream stream = resource.openStream()) { return loadProperties(stream); } catch (IOException e) { LOG.warn("Failed to read properties from {}: {}", resource, e.toString()); return null; } }
/** * Loads properties from the given file. * * @param filePath the absolute path of the file to load properties * @return a set of properties on success, or null if failed */ @Nullable public static Properties loadPropertiesFromFile(String filePath) { try (FileInputStream fileInputStream = new FileInputStream(filePath)) { return loadProperties(fileInputStream); } catch (FileNotFoundException e) { return null; } catch (IOException e) { LOG.warn("Failed to close property input stream from {}: {}", filePath, e.toString()); return null; } }
/** * Loads properties from a resource. * * @param resource url of the properties file * @return a set of properties on success, or null if failed */ @Nullable public static Properties loadPropertiesFromResource(URL resource) { try (InputStream stream = resource.openStream()) { return loadProperties(stream); } catch (IOException e) { LOG.warn("Failed to read properties from {}: {}", resource, e.toString()); return null; } }
/** * Loads properties from the given file. * * @param filePath the absolute path of the file to load properties * @return a set of properties on success, or null if failed */ @Nullable public static Properties loadPropertiesFromFile(String filePath) { try (FileInputStream fileInputStream = new FileInputStream(filePath)) { return loadProperties(fileInputStream); } catch (FileNotFoundException e) { return null; } catch (IOException e) { LOG.warn("Failed to close property input stream from {}: {}", filePath, e.toString()); return null; } }