-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathYamlEncodingExample.java
32 lines (23 loc) · 1008 Bytes
/
YamlEncodingExample.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
package org.simpleyaml.examples;
import java.io.IOException;
import java.nio.charset.Charset;
import org.simpleyaml.configuration.file.YamlFile;
/**
* This example shows you how to use unicode values.
*/
public class YamlEncodingExample {
public static void main(final String[] args) throws IOException {
final YamlFile yamlFile = new YamlFile("examples/test-encoding.yml");
yamlFile.set("encoding.default", Charset.defaultCharset().name());
yamlFile.set("encoding.charset", yamlFile.options().charset().name());
yamlFile.set("encoding.unicode", yamlFile.options().isUnicode());
yamlFile.setComment("encoding.unicode", "Should be true to display values properly");
yamlFile.set("ö", "ö");
yamlFile.set("umlauts", "öüäß");
yamlFile.set("hiragana", "ひらがな");
yamlFile.set("kanji", "漢字");
yamlFile.set("emoji", "\uD83D\uDE01");
System.out.println(yamlFile);
yamlFile.save();
}
}