public class TarArchiveOutputStream extends ArchiveOutputStream
| Modifier and Type | Field and Description |
|---|---|
private byte[] |
assemBuf |
private int |
assemLen |
protected TarBuffer |
buffer |
private boolean |
closed |
private long |
currBytes |
private java.lang.String |
currName |
private long |
currSize |
private boolean |
finished
indicates if this archive is finished
|
private boolean |
haveUnclosedEntry
Indicates if putArchiveEntry has been called without closeArchiveEntry
|
static int |
LONGFILE_ERROR
Fail if a long file name is required in the archive.
|
static int |
LONGFILE_GNU
GNU tar extensions are used to store long file names in the archive.
|
static int |
LONGFILE_TRUNCATE
Long paths will be truncated in the archive.
|
private int |
longFileMode |
private java.io.OutputStream |
out |
private byte[] |
recordBuf |
| Constructor and Description |
|---|
TarArchiveOutputStream(java.io.OutputStream os)
Constructor for TarInputStream.
|
TarArchiveOutputStream(java.io.OutputStream os,
int blockSize)
Constructor for TarInputStream.
|
TarArchiveOutputStream(java.io.OutputStream os,
int blockSize,
int recordSize)
Constructor for TarInputStream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the underlying OutputStream.
|
void |
closeArchiveEntry()
Close an entry.
|
ArchiveEntry |
createArchiveEntry(java.io.File inputFile,
java.lang.String entryName)
Create an archive entry using the inputFile and entryName provided.
|
void |
finish()
Ends the TAR archive without closing the underlying OutputStream.
|
void |
flush() |
int |
getRecordSize()
Get the record size being used by this stream's TarBuffer.
|
void |
putArchiveEntry(ArchiveEntry archiveEntry)
Put an entry on the output stream.
|
void |
setLongFileMode(int longFileMode)
Set the long file mode.
|
void |
write(byte[] wBuf,
int wOffset,
int numToWrite)
Writes bytes to the current tar archive entry.
|
private void |
writeEOFRecord()
Write an EOF (end of archive) record to the tar archive.
|
canWriteEntryData, count, count, getBytesWritten, getCount, writepublic static final int LONGFILE_ERROR
public static final int LONGFILE_TRUNCATE
public static final int LONGFILE_GNU
private long currSize
private java.lang.String currName
private long currBytes
private final byte[] recordBuf
private int assemLen
private final byte[] assemBuf
protected final TarBuffer buffer
private int longFileMode
private boolean closed
private boolean haveUnclosedEntry
private boolean finished
private final java.io.OutputStream out
public TarArchiveOutputStream(java.io.OutputStream os)
os - the output stream to usepublic TarArchiveOutputStream(java.io.OutputStream os,
int blockSize)
os - the output stream to useblockSize - the block size to usepublic TarArchiveOutputStream(java.io.OutputStream os,
int blockSize,
int recordSize)
os - the output stream to useblockSize - the block size to userecordSize - the record size to usepublic void setLongFileMode(int longFileMode)
longFileMode - the mode to usepublic void finish()
throws java.io.IOException
finish in class ArchiveOutputStreamjava.io.IOException - on errorpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.OutputStreamjava.io.IOException - on errorpublic int getRecordSize()
public void putArchiveEntry(ArchiveEntry archiveEntry) throws java.io.IOException
putArchiveEntry in class ArchiveOutputStreamarchiveEntry - The TarEntry to be written to the archive.java.io.IOException - on errorjava.lang.ClassCastException - if archiveEntry is not an instance of TarArchiveEntrypublic void closeArchiveEntry()
throws java.io.IOException
closeArchiveEntry in class ArchiveOutputStreamjava.io.IOException - on errorpublic void write(byte[] wBuf,
int wOffset,
int numToWrite)
throws java.io.IOException
write in class java.io.OutputStreamwBuf - The buffer to write to the archive.wOffset - The offset in the buffer from which to get bytes.numToWrite - The number of bytes to write.java.io.IOException - on errorprivate void writeEOFRecord()
throws java.io.IOException
java.io.IOExceptionpublic void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.OutputStreamjava.io.IOExceptionpublic ArchiveEntry createArchiveEntry(java.io.File inputFile, java.lang.String entryName) throws java.io.IOException
createArchiveEntry in class ArchiveOutputStreamjava.io.IOException