I have an array of jsons like this
[
{"submitted":"Bob","limit":0,"ID":123,"target":3},
{"submitted":"Kate","limit":500,"ID":3221,"target":2}
]
I need to find a way how to insert a record into that file, without overwriting the file, or loading everything into memory
currently i'm doing it like this
try (FileWriter file = new FileWriter("C:/test/output.json", true);
BufferedWriter bfile = new BufferedWriter(file);
PrintWriter outFile = new PrintWriter(bfile))
{
outFile.write(obj.toJSONString()+System.lineSeparator());
outFile.flush();
}
catch (IOException e) {
e.printStackTrace();
}