I just tried to do this - have it be a file stream or RandomAccessFile - and found that it is impossible (or at least very difficult) to implement correct commit and cleanup semantics in that setup. Specifically: we should only commit if all *wrapping* output streams (e.g. an ObjectOutputStream or GzipOutputStream) correctly flush their internal state and close. However, they will either call close on the staging stream too early (deleting the file), or they may call it even when they fail (committing a bad file).

The straightforward fix for this is to have the output stream separate from the commit.