public class TarArchiveOutputStream extends ArchiveOutputStream
Modifier and Type | Field and Description |
---|---|
static int |
BIGNUMBER_ERROR
Fail if a big number (e.g.
|
static int |
BIGNUMBER_POSIX
POSIX/PAX extensions are used to store big numbers in the archive.
|
static int |
BIGNUMBER_STAR
star/GNU tar/BSD tar extensions are used to store big number in the archive.
|
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_POSIX
POSIX/PAX extensions are used to store long file names in the archive.
|
static int |
LONGFILE_TRUNCATE
Long paths will be truncated in the archive.
|
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.
|
TarArchiveOutputStream(java.io.OutputStream os,
int blockSize,
int recordSize,
java.lang.String encoding)
Constructor for TarInputStream.
|
TarArchiveOutputStream(java.io.OutputStream os,
int blockSize,
java.lang.String encoding)
Constructor for TarInputStream.
|
TarArchiveOutputStream(java.io.OutputStream os,
java.lang.String encoding)
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() |
long |
getBytesWritten()
Returns the current number of bytes written to this stream.
|
int |
getCount()
Deprecated.
|
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 |
setAddPaxHeadersForNonAsciiNames(boolean b)
Whether to add a PAX extension header for non-ASCII file names.
|
void |
setBigNumberMode(int bigNumberMode)
Set the big number mode.
|
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.
|
canWriteEntryData, count, count, write
public static final int LONGFILE_ERROR
public static final int LONGFILE_TRUNCATE
public static final int LONGFILE_GNU
public static final int LONGFILE_POSIX
public static final int BIGNUMBER_ERROR
public static final int BIGNUMBER_STAR
public static final int BIGNUMBER_POSIX
public TarArchiveOutputStream(java.io.OutputStream os)
os
- the output stream to usepublic TarArchiveOutputStream(java.io.OutputStream os, java.lang.String encoding)
os
- the output stream to useencoding
- name of the encoding to use for file namespublic 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, java.lang.String encoding)
os
- the output stream to useblockSize
- the block size to useencoding
- name of the encoding to use for file namespublic 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 TarArchiveOutputStream(java.io.OutputStream os, int blockSize, int recordSize, java.lang.String encoding)
os
- the output stream to useblockSize
- the block size to userecordSize
- the record size to useencoding
- name of the encoding to use for file namespublic void setLongFileMode(int longFileMode)
longFileMode
- the mode to usepublic void setBigNumberMode(int bigNumberMode)
bigNumberMode
- the mode to usepublic void setAddPaxHeadersForNonAsciiNames(boolean b)
b
- whether to add a PAX extension header for non-ASCII file names.@Deprecated public int getCount()
ArchiveOutputStream
getCount
in class ArchiveOutputStream
public long getBytesWritten()
ArchiveOutputStream
getBytesWritten
in class ArchiveOutputStream
public void finish() throws java.io.IOException
finish
in class ArchiveOutputStream
java.io.IOException
- on errorpublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.OutputStream
java.io.IOException
- on errorpublic int getRecordSize()
public void putArchiveEntry(ArchiveEntry archiveEntry) throws java.io.IOException
putArchiveEntry
in class ArchiveOutputStream
archiveEntry
- 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 ArchiveOutputStream
java.io.IOException
- on errorpublic void write(byte[] wBuf, int wOffset, int numToWrite) throws java.io.IOException
write
in class java.io.OutputStream
wBuf
- 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 errorpublic void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.OutputStream
java.io.IOException
public ArchiveEntry createArchiveEntry(java.io.File inputFile, java.lang.String entryName) throws java.io.IOException
ArchiveOutputStream
createArchiveEntry
in class ArchiveOutputStream
inputFile
- the file to create the entry fromentryName
- name to use for the entryjava.io.IOException
- if an I/O error occurs