-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproperties.java
More file actions
32 lines (27 loc) · 921 Bytes
/
Copy pathproperties.java
File metadata and controls
32 lines (27 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package subdir;
import java.util.Properties;
/* Properties can be set by -D flags on command line,
* are set by the system (eg java.vm.info),
* taken from JAVA_TOOL_OPTIONS (
* eg JAVA_TOOL_OPTIONS="-Dlog4j.configuration=file:/p/a/t/h -Dfoo=bar"),
* and probably other sources
*/
public class properties {
public static void main(String args[]) throws Exception {
Properties props = new Properties();
props.load(System.in);
props.put("foo", "bar");
System.out.println(
"expect default and bar:" +
props.getProperty("nonextant", "default value") +
props.getProperty("foo", "default value for foo")
);
props.list(System.out);
System.out.println("-- End of properties listing --");
String line = System.getProperty("banana");
System.out.println("-- Showing value of 'banana'");
System.out.println(line);
Properties jvm = System.getProperties();
jvm.list(System.out);
}
}