/** * Obtains an instance from a key-value property set. * * @param keyValueMap the key-value property set * @return the properties file */ public static PropertiesFile of(PropertySet keyValueMap) { ArgChecker.notNull(keyValueMap, "keyValueMap"); return new PropertiesFile(keyValueMap); }
/** * Parses the specified source as a properties file. * <p> * This parses the specified character source expecting a properties file format. * The resulting instance can be queried for each key and value. * <p> * Properties files sometimes contain a Unicode Byte Order Mark. * Callers are responsible for handling this, such as by using {@link UnicodeBom}. * * @param source the properties file resource * @return the properties file * @throws UncheckedIOException if an IO exception occurs * @throws IllegalArgumentException if the file cannot be parsed */ public static PropertiesFile of(CharSource source) { ArgChecker.notNull(source, "source"); ImmutableList<String> lines = Unchecked.wrap(() -> source.readLines()); PropertySet keyValues = parse(lines); return new PropertiesFile(keyValues); }