本文整理汇总了Java中net.sf.sevenzipjbinding.ISevenZipInArchive类的典型用法代码示例。如果您正苦于以下问题:Java ISevenZipInArchive类的具体用法?Java ISevenZipInArchive怎么用?Java ISevenZipInArchive使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ISevenZipInArchive类属于net.sf.sevenzipjbinding包,在下文中一共展示了ISevenZipInArchive类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import net.sf.sevenzipjbinding.ISevenZipInArchive; //导入依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
logger().info("Extracting: {}", sevenArchive());
logger().info("Destination: {}", sevenFolder());
final RandomAccessFile randomAccessFile = new RandomAccessFile(
sevenArchive(), "r");
final ISevenZipInArchive inArchive = SevenZip.openInArchive(
sevenFormat(), new RandomAccessFileInStream(
randomAccessFile));
logger().info("Archive format: {}",
inArchive.getArchiveFormat().name());
final int[] itemList = new int[inArchive.getNumberOfItems()];
for (int index = 0; index < itemList.length; index++) {
itemList[index] = index;
}
final IArchiveExtractCallback callback = new SevenExtractCallback(
inArchive, new File(sevenFolder()), logger());
inArchive.extract(itemList, false, callback);
} catch (final Throwable e) {
logger().error("", e);
throw new MojoExecutionException("", e);
}
}
示例2: SevenExtractCallback
import net.sf.sevenzipjbinding.ISevenZipInArchive; //导入依赖的package包/类
public SevenExtractCallback(final ISevenZipInArchive inArchive,
final File folder, final Logger logger) {
this.inArchive = inArchive;
this.folder = folder;
this.logger = logger;
}
示例3: MyExtractCallback
import net.sf.sevenzipjbinding.ISevenZipInArchive; //导入依赖的package包/类
public MyExtractCallback(final ISevenZipInArchive inArchive,
final File folder) {
this.inArchive = inArchive;
this.folder = folder;
}
示例4: extract
import net.sf.sevenzipjbinding.ISevenZipInArchive; //导入依赖的package包/类
public boolean extract() {
log.debug("Extracting: {}", path);
try {
long time = System.currentTimeMillis();
if (!FileHelper.isSupported(path, false)) {
/*
* TODO Inform user of invalid filetype.
* Change boolean return to error codes to be passed along to the UI.
*/
return false;
}
RandomAccessFile randomAccessFile = new RandomAccessFile(path.toFile(), "r");
ISevenZipInArchive inArchive = SevenZip.openInArchive(null, new RandomAccessFileInStream(randomAccessFile));
for (ISimpleInArchiveItem item : inArchive.getSimpleInterface().getArchiveItems()) {
final ArchiveFile file = new ArchiveFile();
file.setPath(Paths.get(item.getPath()));
if (item.isFolder()) {
log.debug("{}", item.getPath());
file.setFolder(true);
files.add(file);
continue;
}
ExtractOperationResult result;
final byte[] outputData = new byte[item.getSize().intValue()];
result = item.extractSlow(new ISequentialOutStream() {
int offset = 0;
public int write(byte[] data) throws SevenZipException {
for (int i = 0; i < data.length; i++) {
outputData[i + offset] = data[i];
}
offset += data.length;
return data.length;
}
});
file.setData(outputData);
if (result != ExtractOperationResult.OK) {
return false;
}
files.add(file);
}
inArchive.close();
randomAccessFile.close();
log.debug("Time to extract '{}' to memory: {}ms", path, (System.currentTimeMillis() - time));
return true;
} catch (IOException | SevenZipException e) {
log.error(new ParameterizedMessage("Extracting archive: ", path), e);
return false;
}
}