Class PackInserter.PackStream

java.lang.Object
java.io.OutputStream
org.eclipse.jgit.internal.storage.file.PackInserter.PackStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
Enclosing class:
PackInserter

private class PackInserter.PackStream extends OutputStream
Stream that writes to a pack file.

Backed by two views of the same open file descriptor: a random-access file, and an output stream. Seeking in the file causes subsequent writes to the output stream to occur wherever the file pointer is pointing, so we need to take care to always seek to the end of the file before writing a new object.

Callers should always use seek(long) to seek, rather than reaching into the file member. As long as this contract is followed, calls to write(byte[], int, int) are guaranteed to write at the end of the file, even if there have been intermediate seeks.