本文整理汇总了Java中SevenZip.Archive.SevenZipEntry类的典型用法代码示例。如果您正苦于以下问题:Java SevenZipEntry类的具体用法?Java SevenZipEntry怎么用?Java SevenZipEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SevenZipEntry类属于SevenZip.Archive包,在下文中一共展示了SevenZipEntry类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEntry
import SevenZip.Archive.SevenZipEntry; //导入依赖的package包/类
public SevenZipEntry getEntry(int index) {
SevenZip.Archive.SevenZip.FileItem item = _database.Files.get(index);
int index2 = index;
long crc = -1;
if (item.IsFileCRCDefined) {
crc = item.FileCRC & 0xFFFFFFFFL;
}
long position = -1;
if (item.IsStartPosDefined)
position = item.StartPos;
SevenZipEntry entry = new SevenZipEntry(
item.name,
getPackSize(index2),
item.UnPackSize,
crc,
item.LastWriteTime,
position,
item.IsDirectory,
item.Attributes,
getMethods(index2)
);
return entry;
}
示例2: getEntry
import SevenZip.Archive.SevenZipEntry; //导入依赖的package包/类
public SevenZipEntry getEntry(int index) {
SevenZip.Archive.SevenZip.FileItem item = _database.Files.get(index);
int index2 = index;
long crc = -1;
if (item.IsFileCRCDefined) {
crc = item.FileCRC & 0xFFFFFFFFL;
}
long position = -1;
if (item.IsStartPosDefined)
position = item.StartPos;
SevenZipEntry entry = new SevenZipEntry(
item.name,
getPackSize(index2),
item.UnPackSize,
crc,
item.LastWriteTime,
position,
item.IsDirectory,
item.Attributes,
getMethods(index2)
);
return entry;
}
示例3: listing
import SevenZip.Archive.SevenZipEntry; //导入依赖的package包/类
static void listing(IInArchive archive,Vector<String> listOfNames,boolean techMode) {
if (!techMode) {
System.out.println(" Date Time Attr Size Compressed Name");
System.out.println("-------------- ----- ------------ ------------ ------------");
}
long size = 0;
long packSize = 0;
long nbFiles = 0;
for(int i = 0; i < archive.size() ; i++) {
SevenZipEntry item = archive.getEntry(i);
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT , DateFormat.SHORT );
String str_tm = formatter.format(new java.util.Date(item.getTime()));
if (listOfNames.contains(item.getName())) {
if (techMode) {
System.out.println("Path = " + item.getName());
System.out.println("Size = " + item.getSize());
System.out.println("Packed Size = " + item.getCompressedSize());
System.out.println("Modified = " + str_tm);
System.out.println(" Attributes : " + item.getAttributesString());
long crc = item.getCrc();
if (crc != -1)
System.out.println("CRC = " + Long.toHexString(crc).toUpperCase());
else
System.out.println("CRC =");
System.out.println("Method = " + item.getMethods() );
System.out.println("" );
} else {
System.out.print(str_tm + " " + item.getAttributesString());
System.out.print(String.format("%13d",item.getSize()));
System.out.print(String.format("%13d",item.getCompressedSize()));
System.out.println(" " + item.getName());
}
size += item.getSize();
packSize += item.getCompressedSize();
nbFiles ++;
}
}
if (!techMode) {
System.out.println("-------------- ----- ------------ ------------ ------------");
System.out.print(String.format(" %13d%13d %d files",size,packSize,nbFiles));
}
}
示例4: GetStream
import SevenZip.Archive.SevenZipEntry; //导入依赖的package包/类
public int GetStream(int index,
java.io.OutputStream [] outStream,
int askExtractMode) throws java.io.IOException {
outStream[0] = null;
SevenZipEntry item = _archiveHandler.getEntry(index);
_filePath = item.getName();
if (extractDir != null)
{
_filePath = extractDir + _filePath;
}
//AppDeck appDeck = AppDeck.getInstance();
//_filePath = appDeck.cacheDir + _filePath;
/* Context context = getA
File httpCacheDir = new File(context.getCacheDir(), "http");
_filePath = httpCacheDir + _filePath;*/
File file = new File(_filePath);
switch (askExtractMode) {
case IInArchive.NExtract_NAskMode_kTest:
return HRESULT.S_OK;
case IInArchive.NExtract_NAskMode_kExtract:
try {
isDirectory = item.isDirectory();
if (isDirectory) {
if (file.isDirectory()) {
return HRESULT.S_OK;
}
if (file.mkdirs())
return HRESULT.S_OK;
else
return HRESULT.S_FALSE;
}
File dirs = file.getParentFile();
if (dirs != null) {
if (!dirs.isDirectory())
if (!dirs.mkdirs())
return HRESULT.S_FALSE;
}
long pos = item.getPosition();
if (pos == -1) {
file.delete();
}
java.io.RandomAccessFile outStr = new java.io.RandomAccessFile(_filePath,"rw");
if (pos != -1) {
outStr.seek(pos);
}
outStream[0] = new OutputStream(outStr);
} catch (java.io.IOException e) {
return HRESULT.S_FALSE;
}
return HRESULT.S_OK;
}
// other case : skip ...
return HRESULT.S_OK;
}
示例5: GetStream
import SevenZip.Archive.SevenZipEntry; //导入依赖的package包/类
public int GetStream(int index,
java.io.OutputStream [] outStream,
int askExtractMode) throws java.io.IOException {
outStream[0] = null;
SevenZipEntry item = _archiveHandler.getEntry(index);
_filePath = item.getName();
_filePath = _outputPath + "/" + _filePath;
File file = new File(_filePath);
switch (askExtractMode) {
case IInArchive.NExtract_NAskMode_kTest:
return HRESULT.S_OK;
case IInArchive.NExtract_NAskMode_kExtract:
try {
isDirectory = item.isDirectory();
if (isDirectory) {
if (file.isDirectory()) {
return HRESULT.S_OK;
}
if (file.mkdirs())
return HRESULT.S_OK;
else
return HRESULT.S_FALSE;
}
File dirs = file.getParentFile();
if (dirs != null) {
if (!dirs.isDirectory())
if (!dirs.mkdirs())
return HRESULT.S_FALSE;
}
long pos = item.getPosition();
if (pos == -1) {
file.delete();
}
java.io.RandomAccessFile outStr = new java.io.RandomAccessFile(_filePath,"rw");
if (pos != -1) {
outStr.seek(pos);
}
outStream[0] = new OutputStream(outStr);
} catch (java.io.IOException e) {
return HRESULT.S_FALSE;
}
return HRESULT.S_OK;
}
// other case : skip ...
return HRESULT.S_OK;
}
示例6: GetStream
import SevenZip.Archive.SevenZipEntry; //导入依赖的package包/类
public int GetStream(int index,
java.io.OutputStream [] outStream,
// Updated to pass parent_dir argument [GAB, OpenLogic 2013-10-28]
int askExtractMode, java.io.File parent_dir) throws java.io.IOException {
outStream[0] = null;
SevenZipEntry item = _archiveHandler.getEntry(index);
_filePath = item.getName();
// Updated to create the extracted file under the parent_dir directory [GAB, OpenLogic 2013-10-28]
File file = new File(parent_dir, _filePath);
switch (askExtractMode) {
case IInArchive.NExtract_NAskMode_kTest:
return HRESULT.S_OK;
case IInArchive.NExtract_NAskMode_kExtract:
try {
isDirectory = item.isDirectory();
if (isDirectory) {
if (file.isDirectory()) {
return HRESULT.S_OK;
}
if (file.mkdirs())
return HRESULT.S_OK;
else
return HRESULT.S_FALSE;
}
File dirs = file.getParentFile();
if (dirs != null) {
if (!dirs.isDirectory())
if (!dirs.mkdirs())
return HRESULT.S_FALSE;
}
long pos = item.getPosition();
if (pos == -1) {
file.delete();
}
// Write the extracted contents to the file under the parent_dir directory [GAB, OpenLogic 2013-10-28]
java.io.RandomAccessFile outStr = new java.io.RandomAccessFile(file,"rw");
if (pos != -1) {
outStr.seek(pos);
}
outStream[0] = new OutputStream(outStr);
} catch (java.io.IOException e) {
return HRESULT.S_FALSE;
}
return HRESULT.S_OK;
}
// other case : skip ...
return HRESULT.S_OK;
}