forked from davidjava1991/java17CompleteCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample4.java
More file actions
28 lines (25 loc) · 814 Bytes
/
Copy pathExample4.java
File metadata and controls
28 lines (25 loc) · 814 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
package com.david.class151;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;
public class Example4 {
public static void main(String[] args) {
Properties p = new Properties();
try {
p.load(new FileReader("./in/settings.properties"));
System.out.println(p);
System.out.println("check key : "+p.containsKey("name"));
System.out.println("version = "+p.get("version"));
p.setProperty("name", "paul");
p.store(new FileWriter("./in/settings.properties"), "set name");
System.out.println("file stored");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}