-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPropertiesMethods14.java
37 lines (31 loc) · 1.46 KB
/
PropertiesMethods14.java
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
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.Properties;
public class PropertiesMethods14 {
public static void main(String[] args) throws IOException {
Properties properties = new Properties();
properties.put("A", "1");
properties.put("B", "2");
properties.put("C", "3");
properties.put("D", "4");
properties.put("E", "5");
properties.put("F", "6");
properties.put("G", "7");
properties.put("H", "8");
properties.put("I", "9");
properties.put("J", "10");
System.out.println("Properties elements:" + properties);
// storeToXML(OutputStream os, String comment, Charset charset)
Charset charset = Charset.forName("UTF-8");
OutputStream outputStream = new FileOutputStream("PropertiesMethods5.xml");
properties.storeToXML(outputStream, "This is a comment", charset);
// To make an output stream to a specific location, it will create a XML file in
// that location
// storeToXML(OutputStream os, String comment, Charset charset)
Charset charset1 = Charset.forName("ASCII");
OutputStream outputStream1 = new FileOutputStream("C:\\Users\\bosea\\Java_HashTable\\PropertiesMethods6.xml");
properties.storeToXML(outputStream1, "This is a comment", charset1);
}
}