|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
org.apache.commons.compress.archivers.ArchiveOutputStream
org.apache.commons.compress.archivers.tar.TarArchiveOutputStream
public class TarArchiveOutputStream
The TarOutputStream writes a UNIX tar archive as an OutputStream. Methods are provided to put entries, and then write their contents by writing to this stream using write().
Field Summary | |
---|---|
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 Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class org.apache.commons.compress.archivers.ArchiveOutputStream |
---|
canWriteEntryData, count, count, getBytesWritten, getCount, write |
Methods inherited from class java.io.OutputStream |
---|
write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public 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
Constructor Detail |
---|
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 useMethod Detail |
---|
public void setLongFileMode(int longFileMode)
longFileMode
- the mode to usepublic 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 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 error
java.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 errorprivate void writeEOFRecord() throws java.io.IOException
java.io.IOException
public 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
createArchiveEntry
in class ArchiveOutputStream
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |