Skip to content

mprops/mprops-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multiline properties format for Java

Build Status Coverage Status Maven Central Intellij IDEA plugin License

Format

Any text before the first key
is considered as a comment
~ key1. Keys are 1-line strings started with '~'. Leading/trailing whitespaces are removed
Multiline
Value1
~ key2
Multiline
Value2

Usage

Map<String, String> properties = new MPropsParser().parse(text);

or

Map<String, String> properties = new MPropsParser().parse(new FileReader("path-to-file"));

or with a streaming

new MPropsParser().parse(new FileReader("path-to-file"), new BiConsumer<String, String>(){...});

Using custom key token

// All keys now starts with '>' token: example: "> key \n value".
MPropsParser parser = new MPropsParser(">");

Escaping values

To escape any value use starting ' ' (space) character on any value line that starts with key token. This extra leading space will be removed (not-returned) by parser.

Maven

    <dependency>
        <groupId>com.github.mprops</groupId>
        <artifactId>mprops</artifactId>
        <version>1.1.0</version>
    </dependency>