@Test public void testParseIniFromReader() throws IOException { StringReader srData = new StringReader("[default]\naltus_access_key_id=accesKey\naltus_private_key=privateKey"); Map<String, Properties> result = underTest.parseIni(srData); assertTrue(result.containsKey("default")); assertEquals(result.get("default").getProperty("altus_access_key_id"), "accesKey"); assertEquals(result.get("default").getProperty("altus_private_key"), "privateKey"); }
public Map<String, Properties> parseIni(Reader reader) throws IOException { Map<String, Properties> result = new HashMap<>(); new Properties() { private Properties section; @Override public Object put(Object key, Object value) { String header = String.format("%s %s", key, value).trim(); if (header.startsWith("[") && header.endsWith("]")) { section = new Properties(); return result.put(header.substring(1, header.length() - 1), section); } else { return section.put(key, value); } } @Override public synchronized boolean equals(Object o) { return super.equals(o); } @Override public synchronized int hashCode() { return super.hashCode(); } }.load(reader); return result; }
IniUtil { public Map<String, Properties> parseIni(Reader reader) throws IOException { Map<String, Properties> result = new HashMap<>(); new Properties() { private Properties section; @Override public Object put(Object key, Object value) { String header = String.format("%s %s", key, value).trim(); if (header.startsWith("[") && header.endsWith("]")) { section = new Properties(); return result.put(header.substring(1, header.length() - 1), section); } else { return section.put(key, value); } } @Override public synchronized boolean equals(Object o) { return super.equals(o); } @Override public synchronized int hashCode() { return super.hashCode(); } }.load(reader); return result; } }
IniUtil { public Map<String, Properties> parseIni(Reader reader) throws IOException { Map<String, Properties> result = new HashMap<>(); new Properties() { private Properties section; @Override public Object put(Object key, Object value) { String header = String.format("%s %s", key, value).trim(); if (header.startsWith("[") && header.endsWith("]")) { section = new Properties(); return result.put(header.substring(1, header.length() - 1), section); } else { return section.put(key, value); } } @Override public synchronized boolean equals(Object o) { return super.equals(o); } @Override public synchronized int hashCode() { return super.hashCode(); } }.load(reader); return result; }  }
IniUtil { public Map<String, Properties> parseIni(Reader reader) throws IOException { Map<String, Properties> result = new HashMap<>(); new Properties() { private Properties section; @Override public Object put(Object key, Object value) { String header = String.format("%s %s", key, value).trim(); if (header.startsWith("[") && header.endsWith("]")) { section = new Properties(); return result.put(header.substring(1, header.length() - 1), section); } else { return section.put(key, value); } } @Override public synchronized boolean equals(Object o) { return super.equals(o); } @Override public synchronized int hashCode() { return super.hashCode(); } }.load(reader); return result; }  Map<String, Properties> parseIni(Reader reader); }
IniUtil { public Map<String, Properties> parseIni(Reader reader) throws IOException { Map<String, Properties> result = new HashMap<>(); new Properties() { private Properties section; @Override public Object put(Object key, Object value) { String header = String.format("%s %s", key, value).trim(); if (header.startsWith("[") && header.endsWith("]")) { section = new Properties(); return result.put(header.substring(1, header.length() - 1), section); } else { return section.put(key, value); } } @Override public synchronized boolean equals(Object o) { return super.equals(o); } @Override public synchronized int hashCode() { return super.hashCode(); } }.load(reader); return result; }  Map<String, Properties> parseIni(Reader reader);  }