public final class TarOutputStream
extends java.io.FilterOutputStream
TarInputStream
,
TarEntry
Modifier and Type | Field and Description |
---|---|
static int |
LONGFILE_ERROR
Flag to indicate that an error should be generated if
an attempt is made to write an entry that exceeds the 100 char
POSIX limit.
|
static int |
LONGFILE_GNU
Flag to indicate that entry name should be formatted
according to GNU tar extension if an attempt is made
to write an entry that exceeds the 100 char POSIX
limit.
|
static int |
LONGFILE_TRUNCATE
Flag to indicate that entry name should be truncated if
an attempt is made to write an entry that exceeds the 100 char
POSIX limit.
|
private byte[] |
m_assemBuf |
private int |
m_assemLen |
private TarBuffer |
m_buffer |
private long |
m_currBytes |
private long |
m_currSize |
private int |
m_longFileMode |
private byte[] |
m_oneBuf |
private byte[] |
m_recordBuf |
Constructor and Description |
---|
TarOutputStream(java.io.OutputStream output)
Construct a TarOutputStream using specified input
stream and default block and record sizes.
|
TarOutputStream(java.io.OutputStream output,
int blockSize)
Construct a TarOutputStream using specified input
stream, block size and default record sizes.
|
TarOutputStream(java.io.OutputStream output,
int blockSize,
int recordSize)
Construct a TarOutputStream using specified input
stream, block size and record sizes.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Ends the TAR archive and closes the underlying OutputStream.
|
void |
closeEntry()
Close an entry.
|
(package private) void |
copyEntryContents(java.io.InputStream input)
Copies the contents of the specified stream into current tar
archive entry.
|
void |
finish()
Ends the TAR archive without closing the underlying OutputStream.
|
int |
getRecordSize()
Get the record size being used by this stream's TarBuffer.
|
void |
putNextEntry(TarEntry entry)
Put an entry on the output stream.
|
void |
setBufferDebug(boolean debug)
Sets the debugging flag in this stream's TarBuffer.
|
void |
setLongFileMode(int longFileMode)
Set the mode used to work with entrys exceeding
100 chars (and thus break the POSIX standard).
|
void |
write(byte[] buffer)
Writes bytes to the current tar archive entry.
|
void |
write(byte[] buffer,
int offset,
int count)
Writes bytes to the current tar archive entry.
|
void |
write(int data)
Writes a byte to the current tar archive entry.
|
private void |
writeEOFRecord()
Write an EOF (end of archive) record to the tar archive.
|
public static final int LONGFILE_ERROR
public static final int LONGFILE_TRUNCATE
public static final int LONGFILE_GNU
private int m_longFileMode
private byte[] m_assemBuf
private int m_assemLen
private TarBuffer m_buffer
private long m_currBytes
private long m_currSize
private byte[] m_oneBuf
private byte[] m_recordBuf
public TarOutputStream(java.io.OutputStream output)
output
- stream to create TarOutputStream fromTarBuffer.DEFAULT_BLOCKSIZE
,
TarBuffer.DEFAULT_RECORDSIZE
public TarOutputStream(java.io.OutputStream output, int blockSize)
output
- stream to create TarOutputStream fromblockSize
- the block sizeTarBuffer.DEFAULT_RECORDSIZE
public TarOutputStream(java.io.OutputStream output, int blockSize, int recordSize)
output
- stream to create TarOutputStream fromblockSize
- the block sizerecordSize
- the record sizepublic void setBufferDebug(boolean debug)
debug
- The new BufferDebug valuepublic void setLongFileMode(int longFileMode)
longFileMode
- the modepublic int getRecordSize()
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.FilterOutputStream
java.io.IOException
- when an IO error causes operation to failpublic void closeEntry() throws java.io.IOException
java.io.IOException
- when an IO error causes operation to failpublic void finish() throws java.io.IOException
java.io.IOException
- when an IO error causes operation to failpublic void putNextEntry(TarEntry entry) throws java.io.IOException
entry
- The TarEntry to be written to the archive.java.io.IOException
- when an IO error causes operation to failvoid copyEntryContents(java.io.InputStream input) throws java.io.IOException
input
- The InputStream from which to read entrys datajava.io.IOException
- when an IO error causes operation to failpublic void write(int data) throws java.io.IOException
write
in class java.io.FilterOutputStream
data
- The byte written.java.io.IOException
- when an IO error causes operation to failpublic void write(byte[] buffer) throws java.io.IOException
write
in class java.io.FilterOutputStream
buffer
- The buffer to write to the archive.java.io.IOException
- when an IO error causes operation to failpublic void write(byte[] buffer, int offset, int count) throws java.io.IOException
write
in class java.io.FilterOutputStream
buffer
- The buffer to write to the archive.offset
- The offset in the buffer from which to get bytes.count
- The number of bytes to write.java.io.IOException
- when an IO error causes operation to failprivate void writeEOFRecord() throws java.io.IOException
java.io.IOException
- when an IO error causes operation to fail