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
Is the notion of line is very important to you? Otherwise you could probably serialize a Map in a file, and use it to write or read your objects at a specific index (in that case, the index would be key of the map).
Here’s a little example.