final OutputStream out = Files.newOutputStream(output.toPath());
ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.ZIP, out);
os.putArchiveEntry(new ZipArchiveEntry("testdata/test1.xml"));
IOUtils.copy(Files.newInputStream(file1.toPath()), os);
os.closeArchiveEntry();
os.putArchiveEntry(new ZipArchiveEntry("testdata/test2.xml"));
IOUtils.copy(Files.newInputStream(file2.toPath()), os);
os.closeArchiveEntry();
os.close();
Decompressing a ZIP-File:
final InputStream is = Files.newInputStream(input.toPath()); ArchiveInputStream in = new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.ZIP, is); ZipArchiveEntry entry = (ZipArchiveEntry) in.getNextEntry(); OutputStream out = Files.newOutputStream(dir.toPath().resolve(entry.getName())); IOUtils.copy(in, out); out.close(); in.close();
| Modifier and Type | Field and Description |
|---|---|
| public static final String | APK
Constant (value apk) used to identify the APK archive format. |
| public static final String | APKM
Constant (value apkm) used to identify the APKM archive format. |
| public static final String | APKS
Constant (value apks) used to identify the APKS archive format. |
| public static final String | AR
Constant (value ar) used to identify the AR archive format. |
| private SortedMap | |
| private SortedMap | |
| public static final String | ARJ
Constant (value arj) used to identify the ARJ archive format. |
| public static final String | CPIO
Constant (value cpio) used to identify the CPIO archive format. |
| public static final ArchiveStreamFactory | DEFAULT
The singleton instance using the platform default encoding. |
| public static final String | DUMP
Constant (value dump) used to identify the Unix DUMP archive format. |
| private static final int | |
| private final String | encoding
Entry encoding, null for the platform default. |
| private volatile String | entryEncoding
Entry encoding, null for the default. |
| public static final String | JAR
Constant (value jar) used to identify the JAR archive format. |
| public static final String | SEVEN_Z
Constant (value 7z) used to identify the 7z archive format. |
| private static final int | |
| public static final String | TAR
Constant used to identify the TAR archive format. |
| private static final int | |
| public static final String | XAPK
Constant (value xapk) used to identify the XAPK archive format. |
| public static final String | ZIP
Constant (value zip) used to identify the ZIP archive format. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | ArchiveStreamFactory(final String
the encoding to be used. encoding)Constructs an instance using the specified encoding. |
| Modifier and Type | Method and Description |
|---|---|
| private static Iterable | |
| public < The I extends ArchiveInputStreamArchiveInputStream type. | Returns: the archive input streamthe input stream in)Creates an archive input stream from an input stream, autodetecting the archive type from the first few bytes of the stream. |
| public < The I extends ArchiveInputStreamArchiveInputStream type. | Returns: the archive input streamthe archive name, i.e. ar, arj, zip, tar, jar, cpio, dump or
7z archiverName, final InputStream the input stream in)Creates an archive input stream from an archiver name and an input stream. |
| public <I extends ArchiveInputStream | createArchiveInputStream(final String
the archiver name, i.e. ar,
arj,
zip,
tar,
jar,
cpio,
dump or
7z archiverName, final InputStream the input stream in, final String encoding name or null for the default actualEncoding)Implements org. |
| public < The O extends ArchiveOutputStreamArchiveOutputStream type. | Returns: the archive output streamthe archive name, i.e. ar, zip, tar, jar or cpio archiverName, final OutputStream the output stream out)Creates an archive output stream from an archiver name and an output stream. |
| public <O extends ArchiveOutputStream | createArchiveOutputStream(final String
the archiver name, i.e. ar,
zip,
tar,
jar or
cpio archiverName, final OutputStream the output stream out, final String encoding name or null for the default actualEncoding)Implements org. |
| public static String | Returns: type of archiver if foundinput stream in)Try to determine the type of Archiver |
| public static SortedMap | Returns: An immutable, map from names to provider objectsConstructs a new sorted map from input stream provider names to provider objects. |
| public static SortedMap | Returns: An immutable, map from names to provider objectsConstructs a new sorted map from output stream provider names to provider objects. |
| public SortedMap | |
| public SortedMap | |
| public String | Returns: entry encoding, or null for the archiver defaultGets the encoding to use for arj, jar, ZIP, dump, cpio and tar files, or null for the archiver default. |
| public Set | getInputStreamArchiveNames()
Implements org. |
| public Set | getOutputStreamArchiveNames()
Implements org. |
| pack-priv static void | putAll(final Set<String> names, final ArchiveStreamProvider provider, final TreeMap<String, ArchiveStreamProvider> map)
|
| public void | setEntryEncoding(final String
the entry encoding, null uses the archiver default. entryEncoding)
Deprecated
1.10 use
Sets the encoding to use for arj, jar, ZIP, dump, cpio and tar files.
ArchiveStreamFactory(String) to specify the encoding
|
| private static String |
| APK | back to summary |
|---|---|
| public static final String APK Constant (value apk) used to identify the APK archive format. APK file extensions are .apk, .xapk, .apks, .apkm
| |
| APKM | back to summary |
|---|---|
| public static final String APKM Constant (value apkm) used to identify the APKM archive format. APK file extensions are .apk, .xapk, .apks, .apkm
| |
| APKS | back to summary |
|---|---|
| public static final String APKS Constant (value apks) used to identify the APKS archive format. APK file extensions are .apk, .xapk, .apks, .apkm
| |
| AR | back to summary |
|---|---|
| public static final String AR Constant (value ar) used to identify the AR archive format.
| |
| archiveInputStreamProviders | back to summary |
|---|---|
| private SortedMap<String, ArchiveStreamProvider> archiveInputStreamProviders | |
| archiveOutputStreamProviders | back to summary |
|---|---|
| private SortedMap<String, ArchiveStreamProvider> archiveOutputStreamProviders | |
| ARJ | back to summary |
|---|---|
| public static final String ARJ Constant (value arj) used to identify the ARJ archive format. Not supported as an output stream type.
| |
| CPIO | back to summary |
|---|---|
| public static final String CPIO Constant (value cpio) used to identify the CPIO archive format.
| |
| DEFAULT | back to summary |
|---|---|
| public static final ArchiveStreamFactory DEFAULT The singleton instance using the platform default encoding.
| |
| DUMP | back to summary |
|---|---|
| public static final String DUMP Constant (value dump) used to identify the Unix DUMP archive format. Not supported as an output stream type.
| |
| DUMP_SIGNATURE_SIZE | back to summary |
|---|---|
| private static final int DUMP_SIGNATURE_SIZE | |
| encoding | back to summary |
|---|---|
| private final String encoding Entry encoding, null for the platform default. | |
| entryEncoding | back to summary |
|---|---|
| private volatile String entryEncoding Entry encoding, null for the default. | |
| JAR | back to summary |
|---|---|
| public static final String JAR Constant (value jar) used to identify the JAR archive format.
| |
| SEVEN_Z | back to summary |
|---|---|
| public static final String SEVEN_Z Constant (value 7z) used to identify the 7z archive format.
| |
| SIGNATURE_SIZE | back to summary |
|---|---|
| private static final int SIGNATURE_SIZE | |
| TAR | back to summary |
|---|---|
| public static final String TAR Constant used to identify the TAR archive format.
| |
| TAR_HEADER_SIZE | back to summary |
|---|---|
| private static final int TAR_HEADER_SIZE | |
| XAPK | back to summary |
|---|---|
| public static final String XAPK Constant (value xapk) used to identify the XAPK archive format. APK file extensions are .apk, .xapk, .apks, .apkm
| |
| ZIP | back to summary |
|---|---|
| public static final String ZIP Constant (value zip) used to identify the ZIP archive format.
| |
| ArchiveStreamFactory | back to summary |
|---|---|
| public ArchiveStreamFactory() Constructs an instance using the platform default encoding. | |
| ArchiveStreamFactory | back to summary |
|---|---|
| public ArchiveStreamFactory(final String encoding) Constructs an instance using the specified encoding.
| |
| archiveStreamProviderIterable | back to summary |
|---|---|
| private static Iterable | |
| createArchiveInputStream | back to summary |
|---|---|
| public <I extends ArchiveInputStream Creates an archive input stream from an input stream, autodetecting the archive type from the first few bytes of the stream. The InputStream must support marks, like BufferedInputStream.
| |
| createArchiveInputStream | back to summary |
|---|---|
| public <I extends ArchiveInputStream Creates an archive input stream from an archiver name and an input stream.
| |
| createArchiveInputStream | back to summary |
|---|---|
| public <I extends ArchiveInputStream Implements org. Doc from org. Creates an archive input stream from an archiver name and an input stream.
| |
| createArchiveOutputStream | back to summary |
|---|---|
| public <O extends ArchiveOutputStream Creates an archive output stream from an archiver name and an output stream.
| |
| createArchiveOutputStream | back to summary |
|---|---|
| public <O extends ArchiveOutputStream Implements org. Doc from org. Creates an archive output stream from an archiver name and an output stream.
| |
| detect | back to summary |
|---|---|
| public static String detect(final InputStream in) throws ArchiveException Try to determine the type of Archiver
| |
| findAvailableArchiveInputStreamProviders | back to summary |
|---|---|
| public static SortedMap Constructs a new sorted map from input stream provider names to provider objects. The map returned by this method will have one entry for each provider for which support is available in the current Java virtual machine. If two or more supported provider have the same name then the resulting map will contain just one of them; which one it will contain is not specified. The invocation of this method, and the subsequent use of the resulting map, may cause time-consuming disk or network I/O operations to occur. This method is provided for applications that need to enumerate all of the available providers, for example to allow user provider selection. This method may return different results at different times if new providers are dynamically made available to the current Java virtual machine.
| |
| findAvailableArchiveOutputStreamProviders | back to summary |
|---|---|
| public static SortedMap Constructs a new sorted map from output stream provider names to provider objects. The map returned by this method will have one entry for each provider for which support is available in the current Java virtual machine. If two or more supported provider have the same name then the resulting map will contain just one of them; which one it will contain is not specified. The invocation of this method, and the subsequent use of the resulting map, may cause time-consuming disk or network I/O operations to occur. This method is provided for applications that need to enumerate all of the available providers, for example to allow user provider selection. This method may return different results at different times if new providers are dynamically made available to the current Java virtual machine.
| |
| getArchiveInputStreamProviders | back to summary |
|---|---|
| public SortedMap | |
| getArchiveOutputStreamProviders | back to summary |
|---|---|
| public SortedMap | |
| getEntryEncoding | back to summary |
|---|---|
| public String getEntryEncoding() Gets the encoding to use for arj, jar, ZIP, dump, cpio and tar files, or null for the archiver default.
| |
| getInputStreamArchiveNames | back to summary |
|---|---|
| public Set Implements org. Doc from org. Gets all the input stream archive names for this provider | |
| getOutputStreamArchiveNames | back to summary |
|---|---|
| public Set Implements org. Doc from org. Gets all the output stream archive names for this provider | |
| putAll | back to summary |
|---|---|
| pack-priv static void putAll(final Set<String> names, final ArchiveStreamProvider provider, final TreeMap<String, ArchiveStreamProvider> map) | |
| setEntryEncoding | back to summary |
|---|---|
| public void setEntryEncoding(final String entryEncoding)
Deprecated 1.10 use Sets the encoding to use for arj, jar, ZIP, dump, cpio and tar files. Use null for the archiver default.
| |
| toKey | back to summary |
|---|---|
| private static String toKey(final String name) | |