I'd like to write a large stream of unknown size to a tar file in Java. I know that Apache has the commons compress library which handles tar files, but they require me to know the size in advance. Consider Apache's own example:
TarArchiveEntry entry = new TarArchiveEntry(name);
entry.setSize(size);
tarOutput.putArchiveEntry(entry);
tarOutput.write(contentOfEntry);
tarOutput.closeArchiveEntry();
I will know the size of the entry after I write it, but not before. Isn't there a way that I can write the content and when I finish the size is then written to the header?