public class Archiver
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static interface |
Archiver.ArchiveEntryConsumer |
private static interface |
Archiver.ArchiveEntryCreator |
private static interface |
Archiver.Finisher |
Constructor and Description |
---|
Archiver() |
Modifier and Type | Method and Description |
---|---|
void |
create(ArchiveOutputStream target,
java.io.File directory)
Creates an archive
target by recursively including all
files and directories in directory . |
private void |
create(java.io.File directory,
Archiver.ArchiveEntryCreator creator,
Archiver.ArchiveEntryConsumer consumer,
Archiver.Finisher finisher) |
void |
create(SevenZOutputFile target,
java.io.File directory)
Creates an archive
target by recursively including all
files and directories in directory . |
private void |
create(java.lang.String prefix,
java.io.File directory,
Archiver.ArchiveEntryCreator creator,
Archiver.ArchiveEntryConsumer consumer) |
void |
create(java.lang.String format,
java.io.File target,
java.io.File directory)
Creates an archive
target using the format format by recursively including all files and directories in
directory . |
void |
create(java.lang.String format,
java.io.OutputStream target,
java.io.File directory)
Deprecated.
this method leaks resources
|
void |
create(java.lang.String format,
java.io.OutputStream target,
java.io.File directory,
CloseableConsumer closeableConsumer)
Creates an archive
target using the format format by recursively including all files and directories in
directory . |
void |
create(java.lang.String format,
java.nio.channels.SeekableByteChannel target,
java.io.File directory)
Deprecated.
this method leaks resources
|
void |
create(java.lang.String format,
java.nio.channels.SeekableByteChannel target,
java.io.File directory,
CloseableConsumer closeableConsumer)
Creates an archive
target using the format format by recursively including all files and directories in
directory . |
private boolean |
prefersSeekableByteChannel(java.lang.String format) |
public void create(java.lang.String format, java.io.File target, java.io.File directory) throws java.io.IOException, ArchiveException
target
using the format format
by recursively including all files and directories in
directory
.format
- the archive format. This uses the same format as
accepted by ArchiveStreamFactory
.target
- the file to write the new archive to.directory
- the directory that contains the files to archive.java.io.IOException
- if an I/O error occursArchiveException
- if the archive cannot be created for other reasons@Deprecated public void create(java.lang.String format, java.io.OutputStream target, java.io.File directory) throws java.io.IOException, ArchiveException
target
using the format format
by recursively including all files and directories in
directory
.
This method creates a wrapper around the target stream
which is never closed and thus leaks resources, please use
create(String,OutputStream,File,CloseableConsumer)
instead.
format
- the archive format. This uses the same format as
accepted by ArchiveStreamFactory
.target
- the stream to write the new archive to.directory
- the directory that contains the files to archive.java.io.IOException
- if an I/O error occursArchiveException
- if the archive cannot be created for other reasonspublic void create(java.lang.String format, java.io.OutputStream target, java.io.File directory, CloseableConsumer closeableConsumer) throws java.io.IOException, ArchiveException
target
using the format format
by recursively including all files and directories in
directory
.
This method creates a wrapper around the archive stream and
the caller of this method is responsible for closing it -
probably at the same time as closing the stream itself. The
caller is informed about the wrapper object via the closeableConsumer
callback as soon as it is no longer needed
by this class.
format
- the archive format. This uses the same format as
accepted by ArchiveStreamFactory
.target
- the stream to write the new archive to.directory
- the directory that contains the files to archive.closeableConsumer
- is informed about the stream wrapped around the passed in streamjava.io.IOException
- if an I/O error occursArchiveException
- if the archive cannot be created for other reasons@Deprecated public void create(java.lang.String format, java.nio.channels.SeekableByteChannel target, java.io.File directory) throws java.io.IOException, ArchiveException
target
using the format format
by recursively including all files and directories in
directory
.
This method creates a wrapper around the target channel
which is never closed and thus leaks resources, please use
create(String,SeekableByteChannel,File,CloseableConsumer)
instead.
format
- the archive format. This uses the same format as
accepted by ArchiveStreamFactory
.target
- the channel to write the new archive to.directory
- the directory that contains the files to archive.java.io.IOException
- if an I/O error occursArchiveException
- if the archive cannot be created for other reasonspublic void create(java.lang.String format, java.nio.channels.SeekableByteChannel target, java.io.File directory, CloseableConsumer closeableConsumer) throws java.io.IOException, ArchiveException
target
using the format format
by recursively including all files and directories in
directory
.
This method creates a wrapper around the archive channel and
the caller of this method is responsible for closing it -
probably at the same time as closing the channel itself. The
caller is informed about the wrapper object via the closeableConsumer
callback as soon as it is no longer needed
by this class.
format
- the archive format. This uses the same format as
accepted by ArchiveStreamFactory
.target
- the channel to write the new archive to.directory
- the directory that contains the files to archive.closeableConsumer
- is informed about the stream wrapped around the passed in streamjava.io.IOException
- if an I/O error occursArchiveException
- if the archive cannot be created for other reasonspublic void create(ArchiveOutputStream target, java.io.File directory) throws java.io.IOException, ArchiveException
target
by recursively including all
files and directories in directory
.target
- the stream to write the new archive to.directory
- the directory that contains the files to archive.java.io.IOException
- if an I/O error occursArchiveException
- if the archive cannot be created for other reasonspublic void create(SevenZOutputFile target, java.io.File directory) throws java.io.IOException
target
by recursively including all
files and directories in directory
.target
- the file to write the new archive to.directory
- the directory that contains the files to archive.java.io.IOException
- if an I/O error occursprivate boolean prefersSeekableByteChannel(java.lang.String format)
private void create(java.io.File directory, Archiver.ArchiveEntryCreator creator, Archiver.ArchiveEntryConsumer consumer, Archiver.Finisher finisher) throws java.io.IOException
java.io.IOException
private void create(java.lang.String prefix, java.io.File directory, Archiver.ArchiveEntryCreator creator, Archiver.ArchiveEntryConsumer consumer) throws java.io.IOException
java.io.IOException