Skip to content

Instantly share code, notes, and snippets.

@kristianlm
Created January 25, 2014 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristianlm/8619394 to your computer and use it in GitHub Desktop.
Save kristianlm/8619394 to your computer and use it in GitHub Desktop.
Reading http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html#load(java.io.Reader) and trying to create a challenge properties file for your Java properties-file parser
# this is a comment. see
# http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html#load(java.io.Reader)
! this too. and empty lines are allowed
# this is an space-indented comment
#this is a tab-indented and space-indented comment
# key separators include any unescaped "=", ":" or ws.
key1=value
key2 value
key3:value
# preceeding ws in values are ignored (just as with multiline values)
key4 = value
! this is a comment too (yes it is!)
# you can escape stuff with \
e\=mc2=yes
key2=value with multiple words
# add line terminator
multiline_string=one\ntwo
#################### multiline values ####################
# you can escape newline in values like this:
multiline_again=one \
two \
three
# all but one whitespace before "two" and "three" should be ignored.
# should yield "one two three".
multiline_no_ws=motor\
cycle
# should yield "motorcycle"
#this is allowed:
valueless
# and should yield key valueless to have the string "".
# there, easy. this is tricky part, don't escape this:
non_multiline=one\\
# that should give us the string "one" with a single backslash \
back_to_multiline=one\\\
two
# comment indicator must be *first* non-ws character:
key=value#with#hash#signs
# should yield value "value#with#hash#signs"
# you can also create unicode characters:
# \u0020 is space " "
foo\u0020bar\u0020=\u0020barefoot
# should yield key "foo bar ", value " barefoot"
#comment that does not end with newline, but #!eof :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment