Skip to content

Commit 3000382

Browse files
committed
docs: updated README.md with more info about comments
Clarified how comments work and mentioned that there are actually two different comment characters. Added that to the example as well.
1 parent 183ad48 commit 3000382

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,27 @@ Retrieving values is simple:
9797
```java
9898
p.get("port"); // Returns "8080"
9999
p.getProperty("port"); // Also returns "8080"
100-
p.getComment("port") // Returns ["Port number to", "use for the server"]
100+
p.getComment("port") // Returns ["# Port number to", "# use for the server"]
101101
```
102102

103103
### Comments
104104

105+
Just like with the original `Properties` implementation, lines starting with a
106+
`#` or a `!` are considered comments. Consecutive comments lines that start
107+
with the same comment character and have no other lines in between (not even
108+
empty lines) are considered a single multi-line comment.
109+
110+
```properties
111+
# A single comment line
112+
113+
! A multi-line comment
114+
! spanning two lines
115+
116+
# This is actually a single comment line
117+
! And this is a single comment line too
118+
two=Second value
119+
```
120+
105121
Comments are considered either "free" or "attached", which you could see as either being
106122
just part of the file or attached to a property. For example:
107123

@@ -110,7 +126,7 @@ just part of the file or attached to a property. For example:
110126

111127
one=First value (that has no comment)
112128

113-
# Another free comment
129+
! Another free comment
114130

115131
# An attached comment
116132
two=Second value

0 commit comments

Comments
 (0)