Re: Do any java.io classes support inserting text into a file?
Tom Anderson wrote:
On Tue, 19 Aug 2008, Arne Vajh?j wrote:
Tom Anderson wrote:
[...]
But you could imagine a filesystem which did make efficient inserts
possible. The trick would be to allow partially-filled blocks inside
a file, so that if you want to insert or prepend less than a block's
worth (or some non-integer multiple of a block's worth) of data, you
could partially fill a block, then splice it into the middle of the
file.
It could be done.
But I don't think anyone would.
Probably not!
You are wrong, with 100% probability. I was there.
Because there are really not much usage for it.
Hmm. No, you're probably right. It might be useful if you were very
limited in RAM, but if you have a decent amount of memory, then cacheing
makes the rewrite-the-whole-file approach sufficiently efficient.
If the size of the file exceeds the size of the cache,
this is nonsense. Even a big cache can do no more than stave
off the delay of rewriting; the rewriting and its consequent
I/O must happen eventually in any case.
If there was an application which manipulated large files, needed to
make random, variable-sized insertions into them, and needed to run
fast, then such a filesystem would be useful. However, i suspect that
such applications don't exist, [...]
I repeat: I was there. You, obviously, were not there,
so it ill-becomes you to speak whereof you wottest not.
--
Eric Sosman
esosman@ieee-dot-org.invalid