-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo01Properties.java
More file actions
61 lines (42 loc) · 1.52 KB
/
Copy pathDemo01Properties.java
File metadata and controls
61 lines (42 loc) · 1.52 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package Demo13;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;
public class Demo01Properties {
public static void main(String[] args) throws IOException {
show03();
}
private static void show03() throws IOException{
Properties prop = new Properties();
prop.load(new FileReader("src\\Demo13\\prop.txt"));
Set<String> set = prop.stringPropertyNames();
for (String key : set) {
//System.out.println(key+"="+ prop.getProperty(key));
String value = prop.getProperty(key);
System.out.println(key+"="+value);
}
}
private static void show02() throws IOException {
Properties prop = new Properties();
prop.setProperty("Alice", "168");
prop.setProperty("Belle", "160");
prop.setProperty("Cathy","165");
FileWriter fw = new FileWriter("src\\Demo13\\prop.txt");
prop.store(fw, "save data");
fw.close();
}
private static void show01() {
Properties prop = new Properties();
prop.setProperty("Alice", "168");
prop.setProperty("Belle", "160");
prop.setProperty("Cathy","165");
// prop.put(1,true);
Set<String> set = prop.stringPropertyNames();
for (String key : set) {
String value = prop.getProperty(key);
System.out.println(key+"="+value);
}
}
}