读写文件,可以通过Files.readString() / Files.writeString()
同时,删除文件也可以使用Files.delete()
String pathStr = getHome();
try {
Path of = Path.of(pathStr);
String s = Files.readString(of, StandardCharsets.UTF_8);
JsonObject json = new JsonObject(s);
json.put("sss","sss");
System.out.println(json);
Path path = Files.writeString(of, json.toString(), StandardOpenOption.WRITE);
System.out.println(path);
} catch (IOException e) {
throw new RuntimeException(e);
}