java - JAVA 在 YAML 文件中删除和写入键和值
问题描述
1-我想用Java解析我的yaml文件,但是这种方法每次执行时都会写入密钥我需要在写入之前删除以避免重复输入请帮助
我的 yaml file.yaml 的内容
dataPrerequis:
codeClient: 12345df
codeClient: 12345d
方法:
public static void getTestDumpWriter(String yamlFile,String key1,String
value1) throws IOException {
Map<String, Object> data = new HashMap<String, Object>();
data.put(key1, value1);
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setSplitLines(`enter code here`false);
Yaml yaml = new Yaml(options);
BufferedWriter writer =
new BufferedWriter(new FileWriter(yamlFile, true));
yaml.dump(data, writer);
}
解决方案
推荐阅读
- mysql - MYSQL HAVING (not) with ROW_NUMBER() 为什么它返回不同的行数
- curve-fitting - 模拟数据的曲线拟合不起作用
- jenkins - 神器收集问题
- qt - 为什么 QT GUI 对流程图性能的影响如此之大?
- amazon-web-services - 何时应该使用自动缩放以及何时使用 SQS?
- javascript - treeshake后如何在webpack中获取包中的文件列表
- python - Guido van Rossum 在哪里以及在什么情况下说“如果你希望你的代码运行得更快,你应该只使用 PyPy。”?
- html - 如何在链接下添加一个点
- objective-c - 如何在 main.m 中引用私有实例变量
- javascript - 基于绝对div内的滚动位置动画元素溢出:滚动