Package org.openl.util
Class PropertiesUtils
java.lang.Object
org.openl.util.PropertiesUtils
An utility for working with properties files. Parsing, storing.
- Author:
- Yury Molchan
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidload(InputStream input, BiConsumer<? super String, ? super String> result) Loads properties from theInputStreamin UTF-8.static voidload(Reader input, BiConsumer<? super String, ? super String> result) Loads properties in the similar manner, like inProperties.static voidload(URL url, BiConsumer<? super String, ? super String> result) Loads properties from theURLin UTF-8.static voidload(Path path, BiConsumer<? super String, ? super String> result) Loads properties from thePathin UTF-8.static <T extends Map.Entry<?,?>>
voidstore(OutputStream output, Iterable<T> props) Stores properties to theOutputStreamin UTF-8.static <T extends Map.Entry<?,?>>
voidWrites properties in the output.static <T extends Map.Entry<?,?>>
voidStores properties to the file byPathin UTF-8.
-
Method Details
-
load
public static void load(Reader input, BiConsumer<? super String, ? super String> result) throws IOExceptionLoads properties in the similar manner, like inProperties. The difference is in processing whitespaces in keys. This implementation keeps all whitespaces inside keys. For example" A some key = A some value " => key="A some key" , value="A some value "- Parameters:
input- a reader of propertiesresult- a target function, where key/value properties pair will be sent- Throws:
IOException- See Also:
-
load
public static void load(InputStream input, BiConsumer<? super String, ? super String> result) throws IOExceptionLoads properties from theInputStreamin UTF-8.- Throws:
IOException- See Also:
-
load
public static void load(Path path, BiConsumer<? super String, ? super String> result) throws IOExceptionLoads properties from thePathin UTF-8.- Throws:
IOException- See Also:
-
load
public static void load(URL url, BiConsumer<? super String, ? super String> result) throws IOExceptionLoads properties from theURLin UTF-8.- Throws:
IOException- See Also:
-
store
public static <T extends Map.Entry<?,?>> void store(Writer output, Iterable<T> props) throws IOException Writes properties in the output. Serialized properties are restored viaload(Reader, BiConsumer)in the same order and in the same values, excepting where keys are null.- Parameters:
output- a target where properties will be serializedprops- properties- Throws:
IOException
-
store
public static <T extends Map.Entry<?,?>> void store(OutputStream output, Iterable<T> props) throws IOException Stores properties to theOutputStreamin UTF-8.- Throws:
IOException- See Also:
-
store
public static <T extends Map.Entry<?,?>> void store(Path path, Iterable<T> props) throws IOException Stores properties to the file byPathin UTF-8.- Throws:
IOException- See Also:
-