Java Utililty Methods Properties

List of utility methods to do Properties

Description

The list of methods to do Properties are organized into topic(s).

Method

voidsetProperty(Properties props, String keyword, Object value)
set Property
if (props != null) {
    String s = (value != null ? value.toString() : null);
    props.setProperty(keyword, s != null ? s : "");
ListstringPropertyNames(Properties props, String prefix)
string Property Names
if (prefix.endsWith(".")) {
    prefix = prefix.substring(0, prefix.length() - 1);
List<String> keys = new LinkedList<>();
for (String key : props.stringPropertyNames()) {
    if (key.equals(prefix) || key.startsWith(prefix + ".")) {
        keys.add(key);
Collections.sort(keys);
return keys;
PropertiesstringToProperties(String str)
This method converts a comma-separated String (with whitespace optionally allowed after the comma) representing properties to a Properties object.
Properties result = new Properties();
String[] props = str.trim().split(",\\s*");
for (String term : props) {
    int divLoc = term.indexOf("=");
    String key;
    String value;
    if (divLoc >= 0) {
        key = term.substring(0, divLoc);
...
PropertiestoProperties(Map parse)
to Properties
Properties properties = new Properties();
properties.putAll(parse);
return properties;
MaptransformPropertiesToParams(Map properties)
Transform properties to Map of parameters.
Map<String, Object> params = new HashMap<>();
for (Map.Entry<String, String> entry : properties.entrySet()) {
    params.put(entry.getKey(), entry.getValue());
return params;