I'm trying to write line into a file at line-position n.
Even if line n isn't present. In that case the file has to grow with empty lines to reach n. Basically something like writer.writeLine(n, mycontent)
. mycontent is a binary representation from ObjectOutputStream
. Each line of the file contains a serialized object. The line-number is the index.
How can I write to a specific line? - Without using FileUtils or any non-standard API components.
This answer pretty much sums up what I want - but with writing it seems to behave different.
edit: I clarified my question due to the comments