forked from hacker85/JavaLessons
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPropertiesLesson.java
More file actions
26 lines (23 loc) · 984 Bytes
/
PropertiesLesson.java
File metadata and controls
26 lines (23 loc) · 984 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
package properties;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
/**
* Created by husiv on 10/4/16.
*/
public class PropertiesLesson {
public static void main(String[] args) throws IOException {
Properties defaultProperties = new Properties();
defaultProperties.setProperty("height3", "default3");
Properties properties = new Properties(defaultProperties);
// properties.setProperty("width", "200");
// FileOutputStream out = new FileOutputStream("program.properties");
// properties.store(out, "My commets");
FileInputStream in = new FileInputStream("program.properties");
properties.load(in);
System.out.println(properties.getProperty("height"));
System.out.println(properties.getProperty("height2","default height2"));
System.out.println(properties.getProperty("height3"));
System.out.println(System.getProperty("user.home"));
}
}