|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.sevenzipjbinding.SevenZip
public class SevenZip
7-Zip-JBinding main class.
IInArchive
IOutArchive
initSevenZipFromPlatformJAR()
method. This initialization
process requires a platform jar to be in a class path. The automatic initialization starts before the first access to
an archive, if native library wasn't already initialized manually with one of the initSevenZip...
methods. If manual or automatic initialization failed, no further automatic initialization attempts will be made. The
initialization status and error messages can be obtained by following methods:
isInitializedSuccessfully()
- get initialization statusisAutoInitializationWillOccur()
- determine, if an initialization attempt was madegetLastInitializationException()
- get last thrown initialization exceptionsevenzipjbinding-Platform.jar
with one or more native
libraries for respective one or more platforms. Here is some examples of 7-Zip-JBinding platform jar files.
sevenzipjbinding-Linux-i386.jar
with native library for exact one platform: Linux, 32 bitsevenzipjbinding-AllWindows.jar
with native libraries for two platforms: Windows 32 and 64 bitsevenzipjbinding-AllPlatforms.jar
with native libraries for all available platforms/sevenzipjbinding-platforms.properties
file on the class path by calling getPlatformList()
method. The list is cached in a static variable.getPlatformBestMatch
method. If the list of available platforms
contains exact one platform the platform will be always the best match. If more that one platforms are available to
choose from, the system properties os.arch
and os.name
(first part) are used to make the
choice./ChosenPlatform/sevenzipjbinding-lib.properties
on the class path. The list contains names and hashes of
the dynamic libraries located in the /ChosenPlatform/
directory in the same jar.initSevenZipFromPlatformJAR(...)
methods, the temporary
directory is determined using system property java.io.tmpdir
.System.load(String)
method.System.load(String)
or
System.loadLibrary(String)
initLoadedLibraries()
method to initialize manually loaded native libraryAccessController.doPrivileged(java.security.PrivilegedAction)
block. This can be overruled by setting
sevenzip.no_doprivileged_initialization
system property. For example:
java -Dsevenzip.no_doprivileged_initialization=1 ...
createOrVerifyTmpDir
method):
tmpDirectory
parameter of
initSevenZipFromPlatformJAR(File)
or initSevenZipFromPlatformJAR(String, File)
it will be used
java.io.tmpdir
get used
java.io.tmpdir
isn't set, an exception get raised
getTemporaryArtifacts()
. By default,
7-Zip-JBinding doesn't delete those artifacts trying to reduce subsequent initialization overhead. If 7-Zip-JBinding
finds the native libraries within the temporary directory, it uses those without further verification. In order to
allow smoothly updates, the temporary sub-directory with the native libraries named with a unique build reference
number. If 7-Zip-JBinding get updated, a new temporary sub-directory get created and the new native libraries will be
copied and used.
openInArchive(ArchiveFormat, IInStream)
- simple open archive method.openInArchive(ArchiveFormat, IInStream, IArchiveOpenCallback)
- generic open archive method. It's
possible to open all kinds of archives providing call back object that implements following interfaces
IArchiveOpenCallback
- base interface. Must be implemented by all call back classesICryptoGetTextPassword
- (optional) Provides password encrypted indexIArchiveOpenVolumeCallback
- (optional) Provides information about volumes in multipart archives.
Currently used only for multipart RAR
archives. For opening multipart 7z
archives use
VolumedArchiveInStream
.openInArchive(ArchiveFormat, IInStream, String)
a shortcut method for opening password protected
archives with an encrypted index.openOutArchive(ArchiveFormat)
method. It will return an instance of the
IOutCreateArchive
<
IOutItemAllFormats
>
interface allowing creation of an archive of
any supported archive format. To get all currently supported formats see the 'compression' column of the
ArchiveFormat
-JavaDoc.
SevenZip.openOutArchiveXxx
methods, that provide implementations of corresponding
archive format specific interfaces. Those interfaces contain all supported configuration methods for selected archive
format and are more convenient in cases, where only one archive format should be supported.
IOutCreateArchive
.
IInArchive
interface)
IInArchive.getConnectedOutArchive()
to get connected instance of the IOutUpdateArchive
interface
IOutUpdateArchive.updateItems(ISequentialOutStream, int, IOutCreateCallback)
to start the archive
update operation
IOutUpdateArchive
.
Nested Class Summary | |
---|---|
static class |
SevenZip.Version
Version information about 7-Zip. |
Method Summary | |
---|---|
static java.lang.Throwable |
getLastInitializationException()
Returns last native library initialization exception, if occurs. |
static java.lang.String |
getPlatformBestMatch()
Return best match for the current platform out of available platforms availablePlatform |
static java.util.List<java.lang.String> |
getPlatformList()
Load list of the available platforms out of sevenzipjbinding-Platform.jar on the class path. |
static java.lang.String |
getSevenZipJBindingVersion()
Return version of the 7-Zip-JBinding. |
static SevenZip.Version |
getSevenZipVersion()
Return information about native 7-Zip engine. |
static java.io.File[] |
getTemporaryArtifacts()
Returns list of the temporary created artifacts (one directory and one or more files within this directory). |
static java.lang.String |
getUsedPlatform()
Return the platform used for the initialization. |
static void |
initLoadedLibraries()
Initialize 7-Zip-JBinding native library without loading libraries in JVM first. |
static void |
initSevenZipFromPlatformJAR()
Initialize native SevenZipJBinding library assuming sevenzipjbinding-Platform.jar on the
class path. |
static void |
initSevenZipFromPlatformJAR(java.io.File tmpDirectory)
Initialize native SevenZipJBinding library assuming sevenzipjbinding-Platform.jar on the
class path. |
static void |
initSevenZipFromPlatformJAR(java.lang.String platform)
Initialize native SevenZipJBinding library assuming sevenzipjbinding-Platform.jar on the
class path. |
static void |
initSevenZipFromPlatformJAR(java.lang.String platform,
java.io.File tmpDirectory)
Initialize native SevenZipJBinding library assuming sevenzipjbinding-Platform.jar on the
class path. |
static boolean |
isAutoInitializationWillOccur()
Returns weather automatic initialization will occur or not. |
static boolean |
isInitializedSuccessfully()
Tests native library initialization status of SevenZipJBinding. |
static IInArchive |
openInArchive(ArchiveFormat archiveFormat,
IInStream inStream)
Open archive of type archiveFormat from the input stream inStream . |
static IInArchive |
openInArchive(ArchiveFormat archiveFormat,
IInStream inStream,
IArchiveOpenCallback archiveOpenCallback)
Open archive of type archiveFormat from the input stream inStream using 'archive open
call back' listener archiveOpenCallback . |
static IInArchive |
openInArchive(ArchiveFormat archiveFormat,
IInStream inStream,
java.lang.String passwordForOpen)
Open archive of type archiveFormat from the input stream inStream using 'archive open
call-back' listener archiveOpenCallback . |
static IOutCreateArchive<IOutItemAllFormats> |
openOutArchive(ArchiveFormat archiveFormat)
Create a new archive of type archiveFormat . |
static IOutCreateArchive7z |
openOutArchive7z()
Create a new 7z archive. |
static IOutCreateArchiveBZip2 |
openOutArchiveBZip2()
Create a new BZip2 archive. |
static IOutCreateArchiveGZip |
openOutArchiveGZip()
Create a new GZip archive. |
static IOutCreateArchiveTar |
openOutArchiveTar()
Create a new 7z archive. |
static IOutCreateArchiveZip |
openOutArchiveZip()
Create a new Zip archive. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean isInitializedSuccessfully()
getLastInitializationException()
method to get more information in case of initialization failure.
true
7-Zip-JBinding native library was initialized successfully. Native library wasn't
initialized successfully (yet).getLastInitializationException()
,
isAutoInitializationWillOccur()
public static java.lang.Throwable getLastInitializationException()
null
- no initialization exception occurred (yet), else initialization exceptionisInitializedSuccessfully()
public static boolean isAutoInitializationWillOccur()
initSevenZip...
methods. If manual or automatic initialization failed, no further automatic initialization attempts will be made.
true
automatic initialization will occur, false
automatic initialization will
not occurisInitializedSuccessfully()
,
getLastInitializationException()
public static java.lang.String getUsedPlatform()
getPlatformList()
.
null
if initialization wasn't performed yet.getPlatformList()
public static java.util.List<java.lang.String> getPlatformList() throws SevenZipNativeInitializationException
sevenzipjbinding-Platform.jar
on the class path.
SevenZipNativeInitializationException
- indicated problems finding or parsing platform property filepublic static java.io.File[] getTemporaryArtifacts()
File
s.public static void initSevenZipFromPlatformJAR() throws SevenZipNativeInitializationException
sevenzipjbinding-Platform.jar
on the
class path. The platform depended library will be extracted from the jar file and copied to the temporary
directory. Then it will be loaded into JVM using System.load(String)
method. Finally the library specific
native initialization method will be called. Please see JavaDoc of SevenZip
for detailed information.getPlatformBestMatch()
method. Use initSevenZipFromPlatformJAR(String)
to set platform
manually.
SevenZipNativeInitializationException
- indicated problems finding a native library, coping it into the temporary directory or loading it.SevenZip
,
initSevenZipFromPlatformJAR(File)
,
initSevenZipFromPlatformJAR(String)
,
initSevenZipFromPlatformJAR(String, File)
public static void initSevenZipFromPlatformJAR(java.io.File tmpDirectory) throws SevenZipNativeInitializationException
sevenzipjbinding-Platform.jar
on the
class path. The platform depended library will be extracted from the jar file and copied to the temporary
directory. Then it will be loaded into JVM using System.load(String)
method. Finally the library specific
native initialization method will be called. Please see JavaDoc of SevenZip
for detailed information.getPlatformBestMatch()
method. Use initSevenZipFromPlatformJAR(String)
to set platform
manually.
tmpDirectory
- temporary directory to copy native libraries to. This directory must be writable and contain at least
2 MB free space.
SevenZipNativeInitializationException
- indicated problems finding a native library, coping it into the temporary directory or loading it.SevenZip
,
initSevenZipFromPlatformJAR()
,
initSevenZipFromPlatformJAR(String)
,
initSevenZipFromPlatformJAR(String, File)
public static void initSevenZipFromPlatformJAR(java.lang.String platform, java.io.File tmpDirectory) throws SevenZipNativeInitializationException
sevenzipjbinding-Platform.jar
on the
class path. The platform depended library will be extracted from the jar file and copied to the temporary
directory. Then it will be loaded into JVM using System.load(String)
method. Finally the library specific
native initialization method will be called. Please see JavaDoc of SevenZip
for detailed information.getPlatformBestMatch()
method. Use initSevenZipFromPlatformJAR(String)
to set platform
manually.
tmpDirectory
- temporary directory to copy native libraries to. This directory must be writable and contain at least
2 MB free space.platform
- Platform to load native library for. The platform must be one of the elements of the list of available
platforms returned by getPlatformList()
.
SevenZipNativeInitializationException
- indicated problems finding a native library, coping it into the temporary directory or loading it.SevenZip
,
initSevenZipFromPlatformJAR()
,
initSevenZipFromPlatformJAR(File)
,
initSevenZipFromPlatformJAR(String)
,
getPlatformList()
public static void initSevenZipFromPlatformJAR(java.lang.String platform) throws SevenZipNativeInitializationException
sevenzipjbinding-Platform.jar
on the
class path. The platform depended library will be extracted from the jar file and copied to the temporary
directory. Then it will be loaded into JVM using System.load(String)
method. Finally the library specific
native initialization method will be called. Please see JavaDoc of SevenZip
for detailed information.getPlatformBestMatch()
method. Use initSevenZipFromPlatformJAR(String)
to set platform
manually.
platform
- Platform to load native library for. The platform must be one of the elements of the list of available
platforms returned by getPlatformList()
.
SevenZipNativeInitializationException
- indicated problems finding a native library, coping it into the temporary directory or loading it.SevenZip
,
initSevenZipFromPlatformJAR()
,
initSevenZipFromPlatformJAR(File)
,
initSevenZipFromPlatformJAR(String, File)
,
getPlatformList()
public static void initLoadedLibraries() throws SevenZipNativeInitializationException
SevenZipNativeInitializationException
- in case of an initialization errorpublic static IInArchive openInArchive(ArchiveFormat archiveFormat, IInStream inStream, IArchiveOpenCallback archiveOpenCallback) throws SevenZipException
archiveFormat
from the input stream inStream
using 'archive open
call back' listener archiveOpenCallback
. To open archive from the file, use
RandomAccessFileInStream
.
archiveFormat
- format of archiveinStream
- input stream to open archive fromarchiveOpenCallback
- archive open call back listener to use. You can optionally implement ICryptoGetTextPassword
to
specify password to use.
IInArchive
which represents opened archive.
SevenZipException
- 7-Zip or 7-Zip-JBinding error occur. Use SevenZipException.printStackTraceExtended()
to get
stack traces of this SevenZipException and of the all thrown 'cause by' exceptions.
java.lang.NullPointerException
- is thrown, if inStream is nullopenInArchive(ArchiveFormat, IInStream, IArchiveOpenCallback)
,
openInArchive(ArchiveFormat, IInStream, String)
public static IInArchive openInArchive(ArchiveFormat archiveFormat, IInStream inStream, java.lang.String passwordForOpen) throws SevenZipException
archiveFormat
from the input stream inStream
using 'archive open
call-back' listener archiveOpenCallback
. To open archive from the file, use
RandomAccessFileInStream
.
archiveFormat
- format of archiveinStream
- input stream to open archive frompasswordForOpen
- password to use. Warning: this password will not be used to extract item from archive but only to open
archive. (7-zip format supports encrypted filename)
IInArchive
which represents opened archive.
SevenZipException
- 7-Zip or 7-Zip-JBinding error occur. Use SevenZipException.printStackTraceExtended()
to get
stack traces of this SevenZipException and of the all thrown 'cause by' exceptions.
java.lang.NullPointerException
- is thrown, if inStream is nullopenInArchive(ArchiveFormat, IInStream)
,
openInArchive(ArchiveFormat, IInStream, IArchiveOpenCallback)
public static IInArchive openInArchive(ArchiveFormat archiveFormat, IInStream inStream) throws SevenZipException
archiveFormat
from the input stream inStream
. To open archive from
the file, use RandomAccessFileInStream
.
archiveFormat
- (optional) format of archive. If null
archive format will be auto-detected.inStream
- input stream to open archive from
IInArchive
which represents opened archive.
SevenZipException
- 7-Zip or 7-Zip-JBinding error occur. Use SevenZipException.printStackTraceExtended()
to get
stack traces of this SevenZipException and of the all thrown 'cause by' exceptions.
java.lang.NullPointerException
- is thrown, if inStream is nullopenInArchive(ArchiveFormat, IInStream)
,
openInArchive(ArchiveFormat, IInStream, String)
public static java.lang.String getPlatformBestMatch() throws SevenZipNativeInitializationException
availablePlatform
SevenZipNativeInitializationException
- is no platform could be chosengetPlatformList()
public static SevenZip.Version getSevenZipVersion()
public static java.lang.String getSevenZipJBindingVersion()
public static IOutCreateArchiveZip openOutArchiveZip() throws SevenZipException
SevenZipException
- 7-Zip or 7-Zip-JBinding error occur. Use SevenZipException.printStackTraceExtended()
to get
stack traces of this SevenZipException and of the all thrown 'cause by' exceptions.IOutCreateArchiveZip
public static IOutCreateArchive7z openOutArchive7z() throws SevenZipException
SevenZipException
- 7-Zip or 7-Zip-JBinding error occur. Use SevenZipException.printStackTraceExtended()
to get
stack traces of this SevenZipException and of the all thrown 'cause by' exceptions.IOutCreateArchive7z
public static IOutCreateArchiveTar openOutArchiveTar() throws SevenZipException
SevenZipException
- 7-Zip or 7-Zip-JBinding error occur. Use SevenZipException.printStackTraceExtended()
to get
stack traces of this SevenZipException and of the all thrown 'cause by' exceptions.IOutCreateArchiveTar
public static IOutCreateArchiveBZip2 openOutArchiveBZip2() throws SevenZipException
SevenZipException
- 7-Zip or 7-Zip-JBinding error occur. Use SevenZipException.printStackTraceExtended()
to get
stack traces of this SevenZipException and of the all thrown 'cause by' exceptions.IOutCreateArchiveBZip2
public static IOutCreateArchiveGZip openOutArchiveGZip() throws SevenZipException
SevenZipException
- 7-Zip or 7-Zip-JBinding error occur. Use SevenZipException.printStackTraceExtended()
to get
stack traces of this SevenZipException and of the all thrown 'cause by' exceptions.IOutCreateArchiveGZip
public static IOutCreateArchive<IOutItemAllFormats> openOutArchive(ArchiveFormat archiveFormat) throws SevenZipException
archiveFormat
.
archiveFormat
- archive format of the new archive
SevenZipException
- 7-Zip or 7-Zip-JBinding error occur. Use SevenZipException.printStackTraceExtended()
to get
stack traces of this SevenZipException and of the all thrown 'cause by' exceptions.IOutCreateArchiveZip
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |