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 kno
If you have only one text file to be added then you can use setSize(long) method and set the size of the entry.
where data is string which you want to be tarred.
long size=data.getByte().length;
TarArchiveEntry entry = new TarArchiveEntry("sample.txt");
entry.setSize(size);
tarOutput.putArchiveEntry(entry);
tarOutput.write(contentOfEntry);
tarOutput.closeArchiveEntry();