I have a text file. It is a simple database, that stores json objects line by line. One json object per one line. Lines are separated with "\n" character.
So my task is to get necessary object from file, deserialize it to java object, change some fields, and write object back to file. Replacing old line with new json line.
Is it possible to make this operation without opening the whole big file to memory, and then saving it? Just replacing bytes in 1 small line.
I read file line by line, and get nessesary line number. I deserialize object and change fields. But I can't find the correct way how to save it according to my goal. I tried FileWriter, BufferedWriter, but it didn't helped.
{"name":"John","surname":"Galt","email":"john@gmail.com"}
{"name":"John2","surname":"Galt","email":"john2@gmail.com"}
{"name":"John3","surname":"Galt","email":"john3@gmail.com"}
{"name":"John4","surname":"Galt","email":"john4@gmail.com"}