|
|
@@ -23,28 +23,9 @@ public class YamlUtils { |
|
|
DumperOptions options = new DumperOptions(); |
|
|
DumperOptions options = new DumperOptions(); |
|
|
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); |
|
|
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); |
|
|
options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN); |
|
|
options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN); |
|
|
options.setPrettyFlow(false); |
|
|
|
|
|
|
|
|
|
|
|
Representer representer = new Representer() { |
|
|
|
|
|
{ |
|
|
|
|
|
// 重写字符串表示方法 |
|
|
|
|
|
representers.put(String.class, new Represent() { |
|
|
|
|
|
public Node representData(Object data) { |
|
|
|
|
|
return representScalar(Tag.STR, (String) data, null); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 去掉引号时使用PLAIN样式 |
|
|
|
|
|
representer.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN); |
|
|
|
|
|
|
|
|
|
|
|
// 创建Yaml实例 |
|
|
// 创建Yaml实例 |
|
|
Yaml yaml = new Yaml(representer, options); |
|
|
|
|
|
|
|
|
|
|
|
String dump = yaml.dump(data); |
|
|
|
|
|
|
|
|
|
|
|
// Yaml yaml = new Yaml(options); |
|
|
|
|
|
|
|
|
Yaml yaml = new Yaml(options); |
|
|
|
|
|
|
|
|
File directory = new File(path); |
|
|
File directory = new File(path); |
|
|
if (!directory.exists()) { |
|
|
if (!directory.exists()) { |
|
|
|