本文整理汇总了Java中SevenZip.Archive.IInArchive.Open方法的典型用法代码示例。如果您正苦于以下问题:Java IInArchive.Open方法的具体用法?Java IInArchive.Open怎么用?Java IInArchive.Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SevenZip.Archive.IInArchive
的用法示例。
在下文中一共展示了IInArchive.Open方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extract
import SevenZip.Archive.IInArchive; //导入方法依赖的package包/类
public static void extract(String filename, String path) throws Exception {
System.out.println("\nJ7zip 4.43 ALPHA 2 (" + Runtime.getRuntime().availableProcessors() + " CPUs)");
MyRandomAccessFile istream = new MyRandomAccessFile(filename,"r");
IInArchive archive = new Handler();
int ret = archive.Open( istream );
if (ret != 0) {
System.out.println("ERROR !");
return ;
}
Vector<String> listOfNames = new Vector<String>();
//listOfNames.add(path);
testOrExtract(archive,listOfNames,IInArchive.NExtract_NAskMode_kExtract);
archive.close();
}
示例2: mainold
import SevenZip.Archive.IInArchive; //导入方法依赖的package包/类
public static void mainold(String[] args) throws Exception {
System.out.println("\nJ7zip 4.43 ALPHA 2 (" + Runtime.getRuntime().availableProcessors() + " CPUs)");
if (args.length < 2) {
PrintHelp();
return ;
}
final int MODE_LISTING = 0;
final int MODE_TESTING = 1;
final int MODE_EXTRACT = 2;
int mode = -1;
Vector<String> listOfNames = new Vector<String>();
for (int i = 2;i < args.length ; i++)
listOfNames.add(args[i]);
if (args[0].equals("l")) {
mode = MODE_LISTING;
} else if (args[0].equals("t")) {
mode = MODE_TESTING;
} else if (args[0].equals("x")) {
mode = MODE_EXTRACT;
} else {
PrintHelp();
return ;
}
String filename = args[1];
MyRandomAccessFile istream = new MyRandomAccessFile(filename,"r");
IInArchive archive = new Handler();
int ret = archive.Open( istream );
if (ret != 0) {
System.out.println("ERROR !");
return ;
}
switch(mode) {
case MODE_LISTING:
listing(archive,listOfNames,false);
break;
case MODE_TESTING:
testOrExtract(archive,listOfNames,IInArchive.NExtract_NAskMode_kTest);
break;
case MODE_EXTRACT:
testOrExtract(archive,listOfNames,IInArchive.NExtract_NAskMode_kExtract);
break;
}
archive.close();
}
示例3: extractAppCache
import SevenZip.Archive.IInArchive; //导入方法依赖的package包/类
public void extractAppCache(SevenZip.IInStream istream, String outputPath) throws IOException
{
// create outputPath if needed
File folder = new File(outputPath);
boolean success = true;
if(!folder.exists()){
success = folder.mkdirs();
}
if (!success){
Log.d(TAG,"Folder not created.");
}
else{
Log.d(TAG,"Folder created!");
}
//RemoteAppCacheRandomAccessFile istream = new RemoteAppCacheRandomAccessFile(inputFile,"r");
IInArchive archive = new Handler();
int ret = archive.Open( istream );
if (ret != 0) {
System.out.println("ERROR !");
return ;
}
//Vector<String> listOfNames = new Vector<String>();
RemoteAppCacheArchiveExtractCallback extractCallbackSpec = new RemoteAppCacheArchiveExtractCallback(outputPath);
IArchiveExtractCallback extractCallback = extractCallbackSpec;
extractCallbackSpec.Init(archive);
extractCallbackSpec.PasswordIsDefined = false;
try {
int len = 0;
int arrays [] = null;
/* if (listOfNames.size() >= 1) {
arrays = new int[listOfNames.size()];
for(int i = 0 ; i < archive.size() ; i++) {
if (listOfNames.contains(archive.getEntry(i).getName())) {
arrays[len++] = i;
}
}
}*/
int res;
//if (len == 0) {
res = archive.Extract(null, -1, IInArchive.NExtract_NAskMode_kExtract , extractCallback);
//} else {
// res = archive.Extract(arrays, len, mode, extractCallback);
//}
if (res == HRESULT.S_OK) {
if (extractCallbackSpec.NumErrors == 0)
System.out.println("Ok Done");
else
System.out.println(" " + extractCallbackSpec.NumErrors + " errors");
} else {
System.out.println("ERROR !!");
}
} catch (java.io.IOException e) {
System.out.println("IO error : " + e.getLocalizedMessage());
}
archive.close();
}
示例4: main
import SevenZip.Archive.IInArchive; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// Added parent_dir to store destination directory [GAB, OpenLogic 2013-10-28]
String parent_dir;
System.out.println("\nJ7zip 4.43 ALPHA 2 (" + Runtime.getRuntime().availableProcessors() + " CPUs)");
if (args.length < 2) {
PrintHelp();
return ;
}
// if the user has passed in a destination directory where
// the extracted file should be written, use that,
// otherwise use the current working directory
if (args.length == 3) {
parent_dir = args[2];
}
else {
parent_dir = System.getProperty("user.dir");
}
final int MODE_LISTING = 0;
final int MODE_TESTING = 1;
final int MODE_EXTRACT = 2;
int mode = -1;
// this was used to pick out specific files to compress or extract
// I'm not using it for our extraction-only tool, but it was too much
// of a pain to remove it everywheere so I'm leaving an empty list as
// a placeholder.
Vector<String> listOfNames = new Vector<String>();
if (args[0].equals("l")) {
mode = MODE_LISTING;
} else if (args[0].equals("t")) {
mode = MODE_TESTING;
} else if (args[0].equals("x")) {
mode = MODE_EXTRACT;
} else {
PrintHelp();
return ;
}
String filename = args[1];
MyRandomAccessFile istream = new MyRandomAccessFile(filename,"r");
IInArchive archive = new Handler();
int ret = archive.Open( istream );
if (ret != 0) {
// System.out.println("ERROR !");
throw new Invalid7zArchiveException("Invalid 7z archive");
// return ;
}
switch(mode) {
case MODE_LISTING:
listing(archive,listOfNames,false);
break;
case MODE_TESTING:
// Updated to include parent_dir argument [GAB, OpenLogic 2013-10-28]
testOrExtract(archive,listOfNames,IInArchive.NExtract_NAskMode_kTest, parent_dir);
break;
case MODE_EXTRACT:
// Updated to include parent_dir argument [GAB, OpenLogic 2013-10-28]
testOrExtract(archive,listOfNames,IInArchive.NExtract_NAskMode_kExtract, parent_dir);
break;
}
archive.close();
}