setProperty() method in the Properties class ensures both the key and the value are strings.
public Object setProperty(String key, String value)
Keys can consist of any Unicode characters except those listed in the following table,
which represent separator characters.
Keys cannot begin with '#' or '!', these characters are reserved to represent comment lines.
However, '#' and '!' are valid at other positions.
Table: Invalid Characters in Keys for Properties
CHARACTERREPRESENTATION
Equals Sign=
Colon:
Space
Tab\t
Newline\n
Return\r
Formfeed\f
import java.io.FileInputStream;
import java.util.Properties;
public class MainClass {
public static void main (String args[]) throws Exception {
Properties p = new Properties();
p.load(new FileInputStream("colon.txt"));
p.list(System.out);
}
}
//File: test.txt
/*
foo:bar
one
two
three=four
five six seven eight
nine ten
*/