Java Utililty Methods Properties Create

List of utility methods to do Properties Create

Description

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

Method

PropertiestoProperties(final Map map)
Gets a new Properties object initialised with the values from a Map.
Properties answer = new Properties();
if (map != null) {
    for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) {
        Map.Entry entry = (Map.Entry) iter.next();
        Object key = entry.getKey();
        Object value = entry.getValue();
        answer.put(key, value);
return answer;
PropertiestoProperties(final String value)
Returns a properties object w/ the key/value pairs parsed from the string passed in.
final Properties ret = new Properties();
if (isNotBlank(value)) {
    try {
        final byte[] bytes = value.getBytes("ISO-8859-1");
        ret.load(new ByteArrayInputStream(bytes));
    } catch (RuntimeException ex) {
        throw ex;
    } catch (Exception ex) {
...
PropertiestoProperties(String jsonStr)
Convert a JSON string to Properties .
return toProperties(toMap(jsonStr));
PropertiestoProperties(String props)
to Properties
Properties p = new Properties();
StringBufferInputStream sbi = new StringBufferInputStream(props);
try {
    p.load(sbi);
} catch (IOException e) {
    throw new RuntimeException("Unexpected Exception Converting String to Properties", e);
return p;
...
StringtoRawString(Properties props)
to Raw String
ByteArrayOutputStream baos = null;
try {
    baos = new ByteArrayOutputStream();
    props.store(baos, "");
    return new String(baos.toByteArray());
} catch (IOException ex) {
    return "";
} finally {
...
inttotalPolicies(Class className)
total Policies
Properties props = new Properties();
InputStream input = className.getResourceAsStream(className.getSimpleName() + ".properties");
props.load(input);
Pattern pattern = Pattern.compile("policyName" + "_" + "policy(\\d)");
Matcher matcher = null;
Set s = props.keySet();
Iterator ite = s.iterator();
int max = 0;
...