当前位置: 首页>>代码示例>>Java>>正文


Java ISevenZipInArchive类代码示例

本文整理汇总了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);
	}
}
 
开发者ID:jwrapper,项目名称:jwrapper-maven-plugin,代码行数:33,代码来源:SevenExtractMojo.java

示例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;
}
 
开发者ID:jwrapper,项目名称:jwrapper-maven-plugin,代码行数:7,代码来源:SevenExtractCallback.java

示例3: MyExtractCallback

import net.sf.sevenzipjbinding.ISevenZipInArchive; //导入依赖的package包/类
public MyExtractCallback(final ISevenZipInArchive inArchive,
		final File folder) {
	this.inArchive = inArchive;
	this.folder = folder;
}
 
开发者ID:jwrapper,项目名称:jwrapper-maven-plugin,代码行数:6,代码来源:ExtractItemsStandardCallback.java

示例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;
	}
	
}
 
开发者ID:KrazyTheFox,项目名称:Starbound-Mod-Manager,代码行数:74,代码来源:Archive.java


注:本文中的net.sf.sevenzipjbinding.ISevenZipInArchive类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。