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


Java ZipFile.extractAll方法代码示例

本文整理汇总了Java中net.lingala.zip4j.core.ZipFile.extractAll方法的典型用法代码示例。如果您正苦于以下问题:Java ZipFile.extractAll方法的具体用法?Java ZipFile.extractAll怎么用?Java ZipFile.extractAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.lingala.zip4j.core.ZipFile的用法示例。


在下文中一共展示了ZipFile.extractAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: unzipfile

import net.lingala.zip4j.core.ZipFile; //导入方法依赖的package包/类
public  void unzipfile(File zipfile, String dest, String passwd) throws ZipException {
	ZipFile zfile = new ZipFile(zipfile);
	// zfile.setFileNameCharset("GBK");//在GBK系统中需要设置
	if (!zfile.isValidZipFile()) {
		throw new ZipException("压缩文件不合法,可能已经损坏!");
	}
	File file = new File(dest);
	if (file.isDirectory() && !file.exists()) {
		file.mkdirs();
	}
	if (zfile.isEncrypted()) {
		zfile.setPassword(passwd.toCharArray());
	}
	zfile.extractAll(dest);

}
 
开发者ID:jiashiwen,项目名称:elasticbak,代码行数:17,代码来源:ZipUtilities.java

示例2: loadWorld

import net.lingala.zip4j.core.ZipFile; //导入方法依赖的package包/类
/**
 * Loads a world. Needs to copy the file from the repo, unzip it and let the implementation load it <br><b>Always
 * needs to call super! Super needs to be called first (because it copies the world)</b>
 *
 * @param map    the map that should be loaded
 * @param gameid the id of the game this map belongs to
 * @return the loaded world
 * @throws WorldException something goes wrong
 */
@Nonnull
public World loadWorld(@Nonnull Map map, @Nonnull UUID gameid, boolean replaceMarkers) {
    map.load(gameid, "TEMP_" + map.getWorldName() + "_" + gameid.toString().split("-")[0]);
    log.finer("Loading map " + map.getInfo().getName() + " as " + map.getLoadedName(gameid));

    File file = new File(worldContainer, map.getLoadedName(gameid));

    try {
        ZipFile zip = new ZipFile(new File(worldsFolder, map.getWorldName() + ".zip"));
        zip.extractAll(file.getAbsolutePath());
        FileUtils.delete(new File(file, "uid.dat"));
    } catch (ZipException e) {
        throw new WorldException("Could not unzip world " + map.getInfo().getName() + ".", e);
    }

    World world = loadLocalWorld(map.getLoadedName(gameid));

    if (replaceMarkers) {
        replaceMarkers(world, map);
    }

    return world;
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLibv2,代码行数:33,代码来源:WorldHandler.java

示例3: decompressZipFile

import net.lingala.zip4j.core.ZipFile; //导入方法依赖的package包/类
public void decompressZipFile(String appName, String filename, String password) {
    String filePath = Environment.getExternalStorageDirectory() + "/" + appName;

    try {
        File src = new File(filePath, filename);
        ZipFile zipFile = new ZipFile(src);

        if (zipFile.isEncrypted())
            zipFile.setPassword(password);

        zipFile.extractAll(filePath);

    } catch (ZipException e) {
        e.printStackTrace();
    }
}
 
开发者ID:sanidhya09,项目名称:androidprojectbase,代码行数:17,代码来源:UtilityClass.java

示例4: testZipSourceBuildSpec

import net.lingala.zip4j.core.ZipFile; //导入方法依赖的package包/类
@Test
public void testZipSourceBuildSpec() throws Exception {
    clearSourceDirectory();
    String buildSpecName = "Buildspec.yml";
    File buildSpec = new File("/tmp/source/" + buildSpecName);
    String buildSpecContents = "yo\n";
    FileUtils.write(buildSpec, buildSpecContents);

    ZipOutputStream out = new ZipOutputStream(new FileOutputStream("/tmp/source.zip"));
    S3DataManager dataManager = createDefaultSource();
    dataManager.zipSource(testZipSourceWorkspace, "/tmp/source/", out, "/tmp/source/");
    out.close();

    File zip = new File("/tmp/source.zip");
    assertTrue(zip.exists());

    File unzipFolder = new File("/tmp/folder/");
    unzipFolder.mkdir();
    ZipFile z = new ZipFile(zip.getPath());
    z.extractAll(unzipFolder.getPath());
    assertTrue(unzipFolder.list().length == 1);
    assertEquals(buildSpecName, unzipFolder.list()[0]);
    File extractedBuildSpec = new File(unzipFolder.getPath() + "/" + buildSpecName);
    assertTrue(FileUtils.readFileToString(extractedBuildSpec).equals(buildSpecContents));
}
 
开发者ID:awslabs,项目名称:aws-codebuild-jenkins-plugin,代码行数:26,代码来源:S3DataManagerTest.java

示例5: downloadDump

import net.lingala.zip4j.core.ZipFile; //导入方法依赖的package包/类
@Before
public void downloadDump() throws IOException, ZipException {
	// TODO use released version of demo dump
	URL website = new URL("https://repo.gentics.com/artifactory/lan.releases/com/gentics/mesh/mesh-demo/0.6.18/mesh-demo-0.6.18-dump.zip");

	FileUtils.deleteDirectory(targetDir);

	ReadableByteChannel rbc = Channels.newChannel(website.openStream());
	File zipFile = new File("target" + File.separator + "dump.zip");
	FileOutputStream fos = new FileOutputStream(zipFile);
	try {
		fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
	} finally {
		fos.close();
	}
	ZipFile zip = new ZipFile(zipFile);
	zip.extractAll(targetDir.getAbsolutePath());
	zipFile.delete();
}
 
开发者ID:gentics,项目名称:mesh,代码行数:20,代码来源:ChangelogSystemTest.java

示例6: downloadAndExtractZip

import net.lingala.zip4j.core.ZipFile; //导入方法依赖的package包/类
private File downloadAndExtractZip(File folder, String command) throws IOException, ZipException {
	File tempZip = File.createTempFile("codr", System.currentTimeMillis() + ".zip");
	downloadFile(tempZip, command);
	ZipFile zipFile = new ZipFile(tempZip);
	tempZip.deleteOnExit();
	File zip;
	zipFile.extractAll((zip = Files.createTempDirectory("codrUnzipped" + System.currentTimeMillis()).toFile()).getAbsolutePath());
	zip.deleteOnExit();
	for (File file : zip.listFiles()) {
		if (file.isFile()) {
			FileUtils.copyFile(file, new File(folder, file.getName()));
		} else {
			new File(folder, file.getName()).mkdirs();
			FileUtils.copyDirectory(file, new File(folder, file.getName()));
		}
	}
	return folder;
}
 
开发者ID:Turnierserver,项目名称:Turnierserver,代码行数:19,代码来源:WebConnector.java

示例7: unzipToFolder

import net.lingala.zip4j.core.ZipFile; //导入方法依赖的package包/类
public static String unzipToFolder(String zip) {
    try {
        File tempDir = new File("temp");
        if (!tempDir.exists()) {
            tempDir.mkdir();
        }
        File folderName = new File(String.format("%s/%d%d", tempDir.getPath(), System.currentTimeMillis(), new Random().nextInt()));
        if (!folderName.exists()) {
            folderName.mkdir();
        }
        System.out.println(zip);
        ZipFile zipFile = new ZipFile(zip);
        zipFile.extractAll(folderName.getAbsolutePath());

        return folderName.getAbsolutePath();
    } catch (ZipException ex) {
        Logger.getLogger(Unzipper.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
}
 
开发者ID:DChaushev,项目名称:JavaEE_AutoGrader,代码行数:21,代码来源:Unzipper.java

示例8: handle

import net.lingala.zip4j.core.ZipFile; //导入方法依赖的package包/类
/**
 * Retrieve the specification file from the remote resource.
 *
 * @param file The downloaded file resource
 * @return The RAML specification file
 * @throws java.lang.IllegalAccessError       Target directory could not be created.
 * @throws java.lang.IllegalArgumentException The target directory is not a directory
 * @throws java.lang.IllegalStateException    The target directory could not be written to or the specification file was not found.
 */
@Override
public File handle(File file) {
    try {
        String targetPath = FilenameUtils.separatorsToUnix(targetDirectory.getPath());
        if (!targetDirectory.exists() && !targetDirectory.mkdirs())
            throw new IllegalAccessError(String.format("Could not create [ %s ] directory.", targetPath));

        if (targetDirectory.exists() && !targetDirectory.isDirectory())
            throw new IllegalArgumentException(String.format("[ %s ] is not a directory.", targetPath));

        if (targetDirectory.exists() && !targetDirectory.canWrite())
            throw new IllegalStateException(String.format("Cannot write to [ %s ].", targetPath));

        ZipFile zipFile = new ZipFile(file);
        zipFile.extractAll(targetDirectory.getPath());

        if (!specificationFile.exists() || !specificationFile.canRead())
            throw new IllegalStateException(String.format("Could not find or access [ %s ].", FilenameUtils.separatorsToUnix(specificationFile.getPath())));

        return specificationFile;
    } catch (ZipException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:ozwolf-software,项目名称:raml-mock-server,代码行数:34,代码来源:ZipArchiveHandler.java

示例9: extractFileContent

import net.lingala.zip4j.core.ZipFile; //导入方法依赖的package包/类
/**
 * Extracts archive content to temp dir and process content.
 *
 * @param name
 * @param file
 * @param path
 * @return Application based on archive content
 * @throws ZipException
 * @throws IOException
 * @throws ObjectNotFoundException
 */
public Application extractFileContent(String name, MultipartFile file, String path)
        throws ZipException, IOException, ObjectNotFoundException {
    if (!checkFileFormat(file, path)) {
        logger.error("File format is wrong.");
        return null;
    }
    String source = getFullFileName(path, file) + file.getOriginalFilename();
    File destinationFolder = new File(getFullFileName(path, file));

    if (!destinationFolder.exists()) {
        if(!destinationFolder.mkdirs()) {
            throw new IOException("Cant create folders");
        }
    }

    ZipFile zipFile = new ZipFile(source);
    zipFile.extractAll(destinationFolder.getPath());

    if (!checkAppContent(destinationFolder.getPath())) {
        logger.error("App content is wrong.");
        return null;
    }
    return extractAppContent(name, path, destinationFolder.getPath(), file);
}
 
开发者ID:ysalmin,项目名称:spring-app-store,代码行数:36,代码来源:StorageUtils.java

示例10: saveRequestBodyToTemporaryDir

import net.lingala.zip4j.core.ZipFile; //导入方法依赖的package包/类
private File saveRequestBodyToTemporaryDir(MultipartFile modelRunZip) throws IOException, ZipException {
    File tempDataDir = null;
    File zipFile = null;
    try {
        zipFile = Files.createTempFile("run", ".zip").toFile();
        modelRunZip.transferTo(zipFile);
        ZipFile zip = new ZipFile(zipFile);
        tempDataDir = Files.createTempDirectory("run").toFile();
        zip.extractAll(tempDataDir.toString());
        return tempDataDir;
    } catch (Exception e) {
        if (tempDataDir != null && tempDataDir.exists()) {
            FileUtils.deleteDirectory(tempDataDir);
        }
        throw e;
    } finally {
        if (zipFile != null && zipFile.exists()) {
            Files.delete(zipFile.toPath());
        }
    }
}
 
开发者ID:SEEG-Oxford,项目名称:ABRAID-MP,代码行数:22,代码来源:ModelRunController.java

示例11: restoreProjectSaikuDB

import net.lingala.zip4j.core.ZipFile; //导入方法依赖的package包/类
private boolean restoreProjectSaikuDB(){
	boolean restoredSaiku = false;
	if( getZippedSaikuProjectDB().exists() ){
		// Unzip file

		try {
			ZipFile zippedProjectSaikuData = new ZipFile( getZippedSaikuProjectDB() );
			zippedProjectSaikuData.extractAll( FolderFinder.getCollectEarthDataFolder() );
			restoredSaiku = true;
		} catch (ZipException e) {
			logger.error("Problems unzipping the contents of the zipped Saiku DB to the local user folder ", e);
		}

	}
	return restoredSaiku;
}
 
开发者ID:openforis,项目名称:collect-earth,代码行数:17,代码来源:AnalysisSaikuService.java

示例12: unzip

import net.lingala.zip4j.core.ZipFile; //导入方法依赖的package包/类
/**
 * 使用给定密码解压指定的ZIP压缩文件到指定目录
 * <p>
 * 如果指定目录不存在,可以自动创建,不合法的路径将导致异常被抛出
 * @param dest 解压目录
 * @param passwd ZIP文件的密码
 * @return  解压后文件数组
 * @throws ZipException 压缩文件有损坏或者解压缩失败抛出
 */
public static File [] unzip(File zipFile, String dest, String passwd) throws ZipException {
    ZipFile zFile = new ZipFile(zipFile);
    zFile.setFileNameCharset("GBK");
    if (!zFile.isValidZipFile()) {
        throw new ZipException("压缩文件不合法,可能被损坏.");
    }
    File destDir = new File(dest);
    if (destDir.isDirectory() && !destDir.exists()) {
        destDir.mkdir();
    }
    if (zFile.isEncrypted()) {
        zFile.setPassword(passwd.toCharArray());
    }
    zFile.extractAll(dest);

    List<FileHeader> headerList = zFile.getFileHeaders();
    List<File> extractedFileList = new ArrayList<File>();
    for(FileHeader fileHeader : headerList) {
        if (!fileHeader.isDirectory()) {
            extractedFileList.add(new File(destDir,fileHeader.getFileName()));
        }
    }
    File [] extractedFiles = new File[extractedFileList.size()];
    extractedFileList.toArray(extractedFiles);
    return extractedFiles;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:36,代码来源:ZipUtil.java

示例13: unzip

import net.lingala.zip4j.core.ZipFile; //导入方法依赖的package包/类
/**
 * Unzips the .dpkg if it's not already unzipped.
 * @throws ZipException if an error happens when unzipping
 */
private void unzip() throws ZipException {
    File tempDir = Files.createTempDir();
    ZipFile zipFile = new ZipFile(apgkFilePath);
    zipFile.extractAll(tempDir.getAbsolutePath());

    unzippedToFolder = tempDir;
}
 
开发者ID:slavetto,项目名称:anki-cards-web-browser,代码行数:12,代码来源:APKGParser.java

示例14: unzipSavegames

import net.lingala.zip4j.core.ZipFile; //导入方法依赖的package包/类
private void unzipSavegames(String cemuDirectory, File outputFile) {
	try {			
		ZipFile zipFile = new ZipFile(outputFile);
	    zipFile.extractAll(cemuDirectory + "/mlc01/usr");
	    outputFile.delete();
	    LOGGER.info("unzip successfull");
	} catch (ZipException e) {
	    LOGGER.error("an error occurred during unziping the file!", e);
	}
}
 
开发者ID:Seil0,项目名称:cemu_UI,代码行数:11,代码来源:CloudController.java

示例15: unzip

import net.lingala.zip4j.core.ZipFile; //导入方法依赖的package包/类
public static void unzip(String targetZipFilePath, String destinationFolderPath, String password) {
    try {
        ZipFile zipFile = new ZipFile(targetZipFilePath);
        if (zipFile.isEncrypted()) {
            zipFile.setPassword(password);
        }
        zipFile.extractAll(destinationFolderPath);

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:ghost1372,项目名称:Mzip-Android,代码行数:13,代码来源:ZipArchive.java


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