List of utility methods to do Properties Create
Properties | toProperties(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; |
Properties | toProperties(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) { ... |
Properties | toProperties(String jsonStr) Convert a JSON string to Properties . return toProperties(toMap(jsonStr));
|
Properties | toProperties(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; ... |
String | toRawString(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 { ... |
int | totalPolicies(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; ... |